SithSolo1
Diamond Member
===== denotes the start and end of a problem area.
public class ConsoleIOTest {
public static void main(String[] args){
System.out.println("This program is designed to calaculate how many boxes of Oaties breakfast");
System.out.println("cereal are contained in one metric ton and the weight of one box of Oaties in");
System.out.println("metric tons. It will also calculate the number of whole cases and extra boxes");
System.out.println("of Oaties in one metric ton.");
System.out.println();
System.out.println("All of this will be done using the weight you supply for one box of Oaties.");
System.out.println();
System.out.println();
double x;
x= 35273.92;
double weight;
===== Here I need to know how to ask them to enter another number if they inter a negative. As it is now it tells them to inter a positive number but it continues on with the calculations. I want it to keep asking them until they enter a positive number or until they have entered 5 or so wrong numbers. If they enter 5 or so wrong numbers I need the program to quit.
System.out.println("Please enter the weight of one box of Oaties ceral in ounces.");
System.out.println("eg.(2, 5.05, 67.2, etc):");
System.out.println();
weight= JLiveRead.readLineDouble();
System.out.println();
if (weight<0){
System.out.println("Please enter a positive number.");
}
=====
===== Here I need to know how to round up to the nearest whole number. I have no clue how I would even start to do that. This would also help on my next problem.
System.out.println("You entered " + weight + " ounces for the weight of one box of Oaties");
System.out.println();
System.out.println("There are " + x/weight
+ " boxes of Oaties in one metric ton.");
System.out.println();
System.out.println("One box of Oaties weighs " + weight/x
+ " metric tons.");
int boxes;
===== Here I need to know how show how many whole cases + extra boxes are in a metric ton. All I have so far is how many cases are in a ton.
System.out.println();
System.out.println("Please enter the number of Oaties boxes in a case.");
System.out.println("eg.(2, 5, 67, etc):");
System.out.println();
boxes= JLiveRead.readLineInt();
System.out.println();
System.out.println("You entered " + boxes + " boxes of Oaties in one case.");
System.out.println();
System.out.println("There are " + x/(boxes*weight)
+ " cases of Oaties in one metric ton.");
=====
}
}
Thx
J
If you don't feel good about doing it for me push me in the right direction with some examples.
public class ConsoleIOTest {
public static void main(String[] args){
System.out.println("This program is designed to calaculate how many boxes of Oaties breakfast");
System.out.println("cereal are contained in one metric ton and the weight of one box of Oaties in");
System.out.println("metric tons. It will also calculate the number of whole cases and extra boxes");
System.out.println("of Oaties in one metric ton.");
System.out.println();
System.out.println("All of this will be done using the weight you supply for one box of Oaties.");
System.out.println();
System.out.println();
double x;
x= 35273.92;
double weight;
===== Here I need to know how to ask them to enter another number if they inter a negative. As it is now it tells them to inter a positive number but it continues on with the calculations. I want it to keep asking them until they enter a positive number or until they have entered 5 or so wrong numbers. If they enter 5 or so wrong numbers I need the program to quit.
System.out.println("Please enter the weight of one box of Oaties ceral in ounces.");
System.out.println("eg.(2, 5.05, 67.2, etc):");
System.out.println();
weight= JLiveRead.readLineDouble();
System.out.println();
if (weight<0){
System.out.println("Please enter a positive number.");
}
=====
===== Here I need to know how to round up to the nearest whole number. I have no clue how I would even start to do that. This would also help on my next problem.
System.out.println("You entered " + weight + " ounces for the weight of one box of Oaties");
System.out.println();
System.out.println("There are " + x/weight
+ " boxes of Oaties in one metric ton.");
System.out.println();
System.out.println("One box of Oaties weighs " + weight/x
+ " metric tons.");
int boxes;
===== Here I need to know how show how many whole cases + extra boxes are in a metric ton. All I have so far is how many cases are in a ton.
System.out.println();
System.out.println("Please enter the number of Oaties boxes in a case.");
System.out.println("eg.(2, 5, 67, etc):");
System.out.println();
boxes= JLiveRead.readLineInt();
System.out.println();
System.out.println("You entered " + boxes + " boxes of Oaties in one case.");
System.out.println();
System.out.println("There are " + x/(boxes*weight)
+ " cases of Oaties in one metric ton.");
=====
}
}
Thx
J
If you don't feel good about doing it for me push me in the right direction with some examples.