You're right... I didn't loop it properly. I modified my While statement to include [nest] both the If and Else statements with the boolean && operators. Here is the proper way to do it (loop). I tested it and now the loop works fine as everything else:Vinyard wrote:Couldn't you just loop this by calling the same function over again?skaterbasist wrote:Code: Select all
//Return to original request System.out.print("Enter the height in integer Inches: "); integerInches=keyboard.nextInt();
Don't know if it's different for C++ or Java.
Code: Select all
//For the hell of it...
import java.io.*;
import java.util.*;
class ForTheHellOfIt
{
public static void main (String args [])
{
int integerInches;
int outputFeet;
int outputInches;
Scanner keyboard = new Scanner (System.in);
System.out.print("Enter height in integer inches: ");
integerInches = keyboard.nextInt();
while (integerInches>0 || integerInches<=0)
{
if (integerInches>0)
//Convert Interger Inches to Feet & Inches
{
outputFeet = integerInches / 12;
outputInches = integerInches % 12;
//Display Integer Inches to Feet & Inches
System.out.println("The height integer inches " +integerInches+ " in feet & inches is " +outputFeet+ " Feet and " +outputInches+" Inches");
integerInches=keyboard.nextInt();
}
else
{
System.out.print("Must be a positive number: ");
integerInches=keyboard.nextInt();
}
}
}
}

