BarChart.java - import [email protected] Lemuel M [email protected] Book Title From Control Structures through Objects by Tony Gaddis Page 269 Challenge 12 Bar

BarChart.java - import [email protected] Lemuel M [email protected]

This preview shows page 1 - 2 out of 2 pages.

import java.util.*; /** * @author Lemuel M. Uhuru * @Date July 15, 2013 * Book Title: From Control Structures through Objects by Tony Gaddis * Page: 269 Challenge 12: Bar Chart * @Description Write a program that asks the user to enter today's * sales for five stores. The program should display a bar chart comparing * each store's sales. Create each bar in the bar chart by displaying a row * of asterisks. Each asterisk should represent $100 of sales. */ public class BarChart { public static void main(String[] args) { // Create Scanner object Scanner input = new Scanner(System.in); // Store sales int sales = 0; System.out.print("Enter today's sales for store 1: "); int sales1 = input.nextInt(); System.out.print("Enter today's sales for store 2: ");
Image of page 1
Image of page 2

You've reached the end of your free preview.

Want to read both pages?

Unformatted text preview: int sales2 = input.nextInt(); System.out.print("Enter today's sales for store 3: "); int sales3 = input.nextInt(); System.out.print("Enter today's sales for store 4: "); int sales4 = input.nextInt(); System.out.print("Enter today's sales for store 5: "); int sales5 = input.nextInt(); // Newline System.out.println(""); // Table Header System.out.println("SALES BAR CHART"); for (int k = 1; k <= 5; k++) { System.out.print("Store " + k + ": "); switch (k) { case 1: sales = sales1; break; case 2: sales = sales2; break; case 3: sales = sales3; break; case 4: sales = sales4; break; case 5: sales = sales5; } for (int l = 1; l <= sales / 100; l++) { System.out.print("*"); } // Newline System.out.println(""); } } }...
View Full Document

  • Spring '08
  • Garcia,D
  • Java Programming, Java Code, Bar chart, $100, @author, Lemuel M. Uhuru

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask You can ask (will expire )
Answers in as fast as 15 minutes
A+ icon
Ask Expert Tutors