Concept explainers
Case Diagram and UML Class Diagram for this java code : (Below the code give some constructive critiques about the UML class diagram)…. Thanks
import java.util.*; public class BeverlyBreads{public static void main(String[] args){Scanner input = new Scanner(System.in); //Array for breads String[] breads = new String[5];
//Bread choices breads[0] = "White Bread"; breads[1] = "Wheat Bread"; breads[2] = "Rye Bread"; breads[3] = "Pumpernickel Bread"; breads[4] = "Baguette";
//Prices for the breads double[] prices = new double[5]; prices[0] = 2.99; prices[1] = 3.49; prices[2] = 3.99; prices[3] = 4.49; prices[4] = 4.99;
//Customer's Name System.out.println("Enter customer's name: "); String name = input.nextLine(); //Customer's Phone Number System.out.println("Enter customer's phone number: "); String phoneNumber = input.nextLine(); //Bread Selection System.out.println("Which bread would you like to order?"); for(int i = 0; i < breads.length; i++) { System.out.println(breads[i] + " " + prices[i]); } int breadSelection = input.nextInt(); switch(breadSelection) { case 1: System.out.println("You've selected " + breads[0] + " " + prices[0]); break; case 2: System.out.println("You've selected " + breads[1] + " " + prices[1]); break; case 3: System.out.println("You've selected " + breads[2] + " " + prices[2]); break; case 4: System.out.println("You've selected " + breads[3] + " " + prices[3]); break; case 5: System.out.println("You've selected " + breads[4] + " " + prices[4]); break; default: System.out.println("You've made an invalid selection"); break; } //Confirmation Page System.out.println("Name: " + name); System.out.println("Phone Number: " + phoneNumber); System.out.println("Bread Selection: " + breads[breadSelection - 1]); System.out.println("Price: " + prices[breadSelection - 1]); } }
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps
- What is causing this error?arrow_forwardpublic class arrayOutput { public static void main (String [] args) { final int NUM_ELEMENTS = 3; int[] userVals = new int [NUM_ELEMENTS]; int i; int sumVal; userVals [0] = 3; userVals [1] = 5; userVals [2] = 8; Type the program's output sumVal = 0; for (i = 0; i < userVals.length; ++i) { sumVal= sumVal + userVals [i]; System.out.println (sumVal); } ? ? ??arrow_forwardJava Input class main { publicstaticvoid main(String args[]) { boolean a =true; boolean b =false; boolean c = a ^ b; System.out.println(!c); } } Find output.arrow_forward
- using System; class Program { publicstaticvoid Main(string[] args) { int number = 1; while (number <= 88) { Console.WriteLine(number); number = number + 2; } int[] randNo = newint[88]; Random r = new Random(); int i=0; while (number <= 88) { randNo[i] = number; number+=1; i+=1; } for (i = 0; i < 3; i++) { Console.WriteLine("Random Numbers between 1 and 88 are " + randNo[r.Next(1, 88)]); } } } this code counts from 1-88 in odds and then selects three different random numbers. it keeps choosing 0 as a random number everytime. how can that be fixed?arrow_forwardusing System; class main { publicstaticvoid Main(string[] args) { int number = 1; while (number <= 88) { int i; Random r = new Random(); int[] randNo=newint[3]; for(i=0;i<3;i++) { randNo[i]= r.Next(1,88); Console.WriteLine("Random Number between 1 and 88 is "+randNo[i]); } } } } This code is supposed to count from 1-88 and then select three random numbers from the list but instead it generates an infinite loop of random numers between 1-88. how can it be fixed?arrow_forwardImage attachedarrow_forward
- Fix all the errors and send the code please // Application looks up home price // for different floor plans // allows upper or lowercase data entry import java.util.*; public class DebugEight3 { public static void main(String[] args) { Scanner input = new Scanner(System.in); String entry; char[] floorPlans = {'A','B','C','a','b','c'} int[] pricesInThousands = {145, 190, 235}; char plan; int x, fp = 99; String prompt = "Please select a floor plan\n" + "Our floorPlanss are:\n" + "A - Augusta, a ranch\n" + "B - Brittany, a split level\n" + "C - Colonial, a two-story\n" + "Enter floorPlans letter"; System.out.println(prompt); entry = input.next(); plan = entry.charAt(1); for(x = 0; x < floorPlans.length; ++x) if(plan == floorPlans[x]) x = fp; if(fp = 99) System.out.println("Invalid floor plan code entered")); else { if(fp…arrow_forward6. Show the printout of the following code: public class ArraysBasic { public static void main(String[] args) { int A[] = {1, 2, 3}; } System.out.println("array A: " + A[0] +""+A[1]+""+ A[2]); System.out.println("array B: " + A[0] + " " + A[1] + " " + A[2]); zeroArray(A); A = new int[5]; System.out.println("array C: " + A[0] + " " + A[1] + " " + A[3] + " " + A[4]); } } public static void zeroArray(int[] list) { for (int j = 0; j < list.length; ++j) { list[j] = 99;arrow_forwardOOP (Object-Oriented Programming) in Java Applying the composite pattern, you may create a replica of any environment you choose. Any number of media may be used, from photographs to simulators to movies to video games, and so on.arrow_forward
- JAVA CODE: check outputarrow_forwardContoh Dalam pemrograman java: class Introduction { public static void main(String args[ ]) { byte x=50.5; System.out.println("Nilai dari variabel x= "+x)3; } ERROR MENGAPA???arrow_forwardFix all errors to make the code compile and complete. //MainValidatorA3 public class MainA3 { public static void main(String[] args) { System.out.println("Welcome to the Validation Tester application"); // Int Test System.out.println("Int Test"); ValidatorNumeric intValidator = new ValidatorNumeric("Enter an integer between -100 and 100: ", -100, 100); int num = intValidator.getIntWithinRange(); System.out.println("You entered: " + num + "\n"); // Double Test System.out.println("Double Test"); ValidatorNumeric doubleValidator = new ValidatorNumeric("Enter a double value: "); double dbl = doubleValidator.getDoubleWithinRange(); System.out.println("You entered: " + dbl + "\n"); // Required String Test System.out.println("Required String Test:"); ValidatorString stringValidator = new ValidatorString("Enter a required string: "); String requiredString =…arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education