HW05 Solution2

# HW05 Solution2 - counts[i] = counts[i] + userOrder }

This preview shows pages 1–2. Sign up to view the full content.

Sheet1 Page 1 // Solution to Homework #5, Problem #2 import java.util.Scanner public class HW5_2 { public static void main(String[] args) { String[] descriptions = {"Soy Burger", "Hamburger", "Cheeseburger", "Double Bypass Burger"} int[] counts counts = new int[descriptions.length] int userOrder Scanner scanner = new Scanner(System.in) for (int i = 0 userOrder = getInt("How many " + descriptions[i] + "s do you want? ")

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: counts[i] = counts[i] + userOrder } System.out.println(&quot;\nYou ordered &quot;) for (int i = 0 System.out.println(counts[i] + &quot; &quot; + descriptions[i] + &quot;(s)&quot;) } } public static int getInt(String prompt) { System.out.print(prompt) Scanner scanner = new Scanner(System.in) return scanner.nextInt() } } Sheet1 Page 2 i &lt; descriptions.length i++) { i &lt; descriptions.length i++) {...
View Full Document

## HW05 Solution2 - counts[i] = counts[i] + userOrder }

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online