Question
FOR JAVA (DEBUG) Please debug the following: ===================================================================== //a program using StringBuilder and a variety of string methods to order from a menu //contains 4
FOR JAVA (DEBUG)
Please debug the following:
===================================================================== //a program using StringBuilder and a variety of string methods to order from a menu //contains 4 bugs. import java.util.Scanner ; public class debug4 { public static void main ( String [ ] args ) { double hamburgerPrice = 2.95 ; double cheeseburgerPrice = 3.45 ; double friesPrice = 1.95 ; double sodaPrice = 1.25 ; double totalPrice ; String item ; int hamburgerQty = 0, cheeseburgerQty = 0, friesQty = 0, sodaQty = 0, qty ; boolean redoOrder = true ; Scanner input = new Scanner ( System. in ) ; System. out. println ( "Hi welcome to Java Burger. " ) ; System. out. println ( "Please type in the names and quantity of items " + "you would like to order followed by a ^ and then press enter. " ) ; System. out. println ( "(limit of 9 items of each type per order)" ) ; System. out. println ( "Example input: \"Cheeseburger4^Fries8^Soda3^\"" ) ; System. out. println ( " Menu" ) ; System. out. print ( "---------------------------" ) ; System. out. printf ( " Hamburger $%.2f",hamburgerPrice ) ; System. out. printf ( " Cheeseburger $%.2f",cheeseburgerPrice ) ; System. out. printf ( " Fries $%.2f",friesPrice ) ; System. out. printf ( " Soda $%.2f ",sodaPrice ) ; StringBuilder order = StringBuilder (nextLine ( ) ) ; while (redoOrder == true ) { //the following for loop is some messy code for parsing the String Builder //no intended bugs in the for loop or switch statement! int j = 0 ; for ( int i = 0 ; i
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started