Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

269
Views
Creating a Histogram Using Arrays and Two Classes

My assignment for intro to CS class was to make a program that a user could enter a letter grade into and then to create a histogram using an array with another class. In the program Z closes the program and it counts mistakes as well. I realize now that I should have just written a command to make the users letter capital but whats done is done and it like won't matter for this program. I believe what shown below works, but I need some help making a second class and array. If someone could help I would greatly appreciate it.

public static void main (String[] args) {
    Scanner scan = new Scanner (System.in);

    int aCount = 0;
    int bCount = 0;
    int cCount = 0;
    int dCount = 0;
    int fCount = 0;
    int mCount = 0;
    int Tscore = -1;
    int count = 0;
    String score;


    while (Tscore == -1)
    { count ++;
    System.out.print("Pleases Enter a Letter Grade or Z to quit");
    score = scan.next() ;
        if (score.equals("a") || score.equals("A")) {
        aCount++ ;
    } else if (score.equals("b") || score.equals("B")) {
        bCount++ ;
    } else if (score.equals("c") || score.equals("C")) {
        cCount++ ;
    } else if (score.equals("d") || score.equals("D")) {
        dCount++ ;
    } else if (score.equals("f") || score.equals("F")) {
       fCount++ ;
    } else if (score != "a" && score != "A" && score != "b" && score != "B" && score != "c" && score != "C" && score != "d" && score != "D" && score != "f" && score != "F" && score != "z" && score != "Z") {
        mCount++ ;
    } else if (score.equals("z") || score.equals("Z")) {
        Tscore++ ;
    }
over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!