windows 7 x64 - How do I get my java program running even though it has no errors? What have I done wrong? How can I make the program run? -
in program supposed ask user whether or not order 1 pizza , if yes, must enter:
their last name (don't worry validating)
,
their choice of pizza type
and
their choice of pizza size.
the choices veggie, cheese, pepperoni, , supreme.
can small, medium, or large.
each person can order 1 pizza. things need validate initial response, types of pizza, , sizes. when compiled program had no errors, when tried run did show code. when "all did show code" mean on browser used showed see in notepad++. ran clicking "run" drop down button on notepad++. gave me options run in different browsers. tried running in mozilla , chrome same results (only showing source code, not running program). advice on how program working??
/*this program keep prompting user enter pizza order, perform requested calculation, , output requested result. written hannah lane*/ import java.util.scanner; public class pizzaorders { public static void main(string[] args) { scanner input = new scanner(system.in); int smallpizzas = 0, mediumpizzas = 0, largepizzas = 0, numberoforders = 0; double totalordercost = 0.0, pizzacost = 0.0, averagecost = 0.0; string custlastname = "", pizzasize = "", pizzatype ="", response = ""; /*the loop prompt user see if customer order pizza. if yes, prompt user last name, choice of pizza type, , choice of pizza size. 2 possible responses yes , no. dummy value loop no. */ system.out.print("do want order 1 pizza?" + "type yes or no (all lower case), press enter key."); response = input.next(); while (!(response.equals("no"))) { /*validate user's response. if valid, prompt required values, perform calculation, , output result. if invalid, output error message. */ if (response.equals("yes")) { system.out.println("please type in last name (it can 1 word) , press enter key."); custlastname = input.next(); system.out.println("please type in choice of pizza in lower case letters. type keyboard must be" + "pepperoni, veggie, cheese, or supreme."); pizzatype = input.next(); system.out.println("please type in choice of pizza size in lower case letters. type keyboard must" + "be small, medium, or large."); pizzasize = input.next(); /* validate entries calculation. sizes must small, medium, or large. types of pizza must pepperoni, veggie, cheese, or supreme. division, must make sure denominator not zero. if invalid, output error message. */ if (pizzatype.equals("pepperoni") || pizzatype.equals("veggie") || pizzatype.equals("cheese") || pizzatype.equals("supreme") && pizzasize.equals("small") || pizzasize.equals("medium") || pizzasize.equals("large") && numberoforders !=0.0) { if (pizzatype.equals ("pepperoni")) { if (pizzasize.equals ("small")) { smallpizzas = smallpizzas + 1; pizzacost = 8.50; totalordercost = totalordercost + 8.50; numberoforders = numberoforders + 1; } else if (pizzasize.equals ("medium")) { mediumpizzas = mediumpizzas + 1; pizzacost = 9.50; totalordercost = totalordercost + 9.50; numberoforders = numberoforders + 1; } else if(pizzasize.equals ("large")) { largepizzas = largepizzas + 1; pizzacost = 10.50; totalordercost = totalordercost + 10.50; numberoforders = numberoforders + 1; } } else if (pizzatype.equals ("veggie")) { if (pizzasize.equals ("small")) { smallpizzas = smallpizzas + 1; pizzacost = 10.00; totalordercost = totalordercost + 10.00; numberoforders = numberoforders + 1; } else if (pizzasize.equals ("medium")) { mediumpizzas = mediumpizzas + 1; pizzacost = 12.25; totalordercost = totalordercost + 12.25; numberoforders = numberoforders + 1; } else if (pizzasize.equals ("large")) { largepizzas = largepizzas + 1; pizzacost = 14.50; totalordercost = totalordercost + 14.50; numberoforders = numberoforders + 1; } } else if (pizzatype.equals ("cheese")) { if (pizzasize.equals ("small")) { smallpizzas = smallpizzas + 1; pizzacost = 7.00; totalordercost = totalordercost + 7.00; numberoforders = numberoforders + 1; } else if (pizzasize.equals ("medium")) { mediumpizzas = mediumpizzas + 1; pizzacost = 8.00; totalordercost = totalordercost + 8.00; numberoforders = numberoforders + 1; } else if (pizzasize.equals ("large")) { largepizzas = largepizzas + 1; pizzacost = 9.00; totalordercost = totalordercost + 9.00; numberoforders = numberoforders + 1; } } else if (pizzatype.equals ("supreme")) { if (pizzasize.equals ("small")) { smallpizzas = smallpizzas + 1; pizzacost = 11.00; totalordercost = totalordercost + 11.00; numberoforders = numberoforders + 1; } else if (pizzasize.equals ("medium")) { mediumpizzas = mediumpizzas + 1; pizzacost = 14.00; totalordercost = totalordercost + 14.00; numberoforders = numberoforders + 1; } else if (pizzasize.equals ("large")) { largepizzas = largepizzas + 1; pizzacost = 16.00; totalordercost = totalordercost + 16.00; numberoforders = numberoforders + 1; } averagecost = totalordercost/(double)numberoforders; system.out.println(custlastname + pizzacost + smallpizzas + mediumpizzas + largepizzas + averagecost); } } } else system.out.println("what have typed in incorrect. response must yes or no."); system.out.println("do want order 1 pizza? type yes or no" + "(all lower case), press enter key."); response = input.next(); } } }
did compiled program before running? you must have jdk installed in pc
steps compile , run java program - 1 ) write java code using text editor , save file classname.java (in case, class name "pizzaorders" ).
2) open command prompt , navigate folder have saves previous file. (i.e pizzaorders.java).
3)run command javac pizzaorders.java.
4)run command java pizzaorders.
Comments
Post a Comment