Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This program inputs letter grades for 20 students in the class then prints out stars representing the number of students who received each grade. For

This program inputs letter grades for 20 students in the class then prints out stars representing the number of students who received each grade. For example if there were 3 A's, 2 B's, 10 C's, 4 D's and 1 F the output would be

A: *** B: ** C: ********** D: **** F: * 

import java.util.Scanner;

public class Number2 {

public static void main(String[] args) { Scanner keyboard = new Scanner(System.in); System.out.println("Enter 20 letter grades"); String grade; int numA=0, numB=0, numC=0, numD=0, numF=0; for (int i=0; i<20; i++) { grade=keyboard.next(); grade=grade.toUpperCase(); grade=grade.substring(0,1); switch(grade) {case "A": numA++;break; case "B":numB++;break; case "C":numC++;break; case "D":numD++;break; case "F":numF++;break; } } printStars(numA, numB, numC, numD, numF); } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Joe Celkos Data And Databases Concepts In Practice

Authors: Joe Celko

1st Edition

1558604324, 978-1558604322

More Books

Students also viewed these Databases questions

Question

What is one of the skills required for independent learning?Explain

Answered: 1 week ago

Question

Explain the importance of nonverbal messages.

Answered: 1 week ago

Question

Describe the advantages of effective listening.

Answered: 1 week ago

Question

Prepare an employment application.

Answered: 1 week ago