Question

JAVA Program According to Sample output to write a program Sample output: Please enter the number...

JAVA Program

According to Sample output to write a program

Sample output:

Please enter the number of student: 4

Please enter the score of student 1: 82

Please enter the score of student 2: 92

Please enter the score of student 3: 84

Please enter the score of student 4: 74

---------------------------------------------------

Student                Score                     Grade

1                              82                           B

2                             92                           A

3                              84                           B

4                              70                           C

0 0
Add a comment Improve this question Transcribed image text
Answer #1

import java.util.Scanner;

public class StudentGrade {
   public static void main(String[] args) {
       Scanner sc = new Scanner(System.in);
       System.out.println("Please enter the number of student: ");
       int n=sc.nextInt();
       int grades[]= new int[n];
       for(int i=0;i<n;i++) {
           System.out.println("Please enter the score of student "+(i+1)+": ");
           grades[i]=sc.nextInt();
       }
       System.out.printf("%-10s%-10s%-10s\n","Student","Score","Grade");
       System.out.println("---------------------------------------------------------");
       for(int i=0;i<n;i++) {
           System.out.printf("%-10d%-10d%-10s\n",i+1,grades[i],getLetterGade(grades[i]));
       }
   }

   private static String getLetterGade(int g) {
       if(g>=90)
           return "A";
       if(g>=80)
           return "B";
       if(g>=70)
           return "C";
       if(g>=60)
           return "D";
       return "F";
   }
}

Note : Please comment below if you have concerns. I am here to help you

If you like my answer please rate and help me it is very Imp for me

Add a comment
Know the answer?
Add Answer to:
JAVA Program According to Sample output to write a program Sample output: Please enter the number...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Java Program: In this project, you will write a program called GradeCalculator that will calculate the...

    Java Program: In this project, you will write a program called GradeCalculator that will calculate the grading statistics of a desired number of students. Your program should start out by prompting the user to enter the number of students in the classroom and the number of exam scores. Your program then prompts for each student’s name and the scores for each exam. The exam scores should be entered as a sequence of numbers separated by blank space. Your program will...

  • This program has to be made in java also will but uploaded on zybooks Write a...

    This program has to be made in java also will but uploaded on zybooks Write a program in Java to read a list of exam grades given as int's in the range of 0 to 100. Your program will display the total number of grades and the number of grades in each letter-grade category as follows: A 93 <= grade <= 100 A- 90 <= grade < 93 B+ 87 <= grade < 90 B 83 <= grade < 87...

  • using java Program: Please read the complete prompt before going into coding. Write a program that...

    using java Program: Please read the complete prompt before going into coding. Write a program that handles the gradebook for the instructor. You must use a 2D array when storing the gradebook. The student ID as well as all grades should be of type int. To make the test process easy, generate the grade with random numbers. For this purpose, create a method that asks the user to enter how many students there are in the classroom. Then, in each...

  • Write a program using "C" in visual studio that: A. Has a function (input()) that allows...

    Write a program using "C" in visual studio that: A. Has a function (input()) that allows the user to enter a list of 10 scores and stores them in an array. B. Has a function (result()) then assigns grades based on the following sheme: 21 Write a program that a Has a function (iaoutO) that allows the user to enter a list of 10 scores and stores therm in an array b. Has a function (resultil then assigns gracdes besed...

  • Write a java program to read a list of exam grades given as int's in the...

    Write a java program to read a list of exam grades given as int's in the range of 0 to 100. Your program will display the total number of grades and the number of grades in each letter-grade category as follows: A 93 <= grade <= 100 A- 90 <= grade < 93 B+ 87 <= grade < 90 B 83 <= grade < 87 B- 80 <= grade < 83 C+ 77 <= grade < 80 C 73 <=...

  • hello. i need help with number 2 ONLY 1. Use if statements to write a Java...

    hello. i need help with number 2 ONLY 1. Use if statements to write a Java program that inputs a single letter and prints out the corresponding digit on the telephone. The letters and digits on a telephone are grouped this way 2=ABC 3 = DEF 4 GHI 5 JKL 6 - MNO 7 - PRS 8 - TUV 9-WXY No digit corresponds to either Qor Z. For these 2 letters your program should print a message indicating that they...

  • (Java Please) Sum of Digits Write a program that will sum the digits of a number...

    (Java Please) Sum of Digits Write a program that will sum the digits of a number input by the user. For example, if the user enters the number 1234, the sum of the digits will be 10 (1 + 2 + 3 + 4 = 10). The user will enter a number with at least 4 digits (greater than 1000). That value will be sent to a method which will return the sum. Sample Output 1: SUM OF DIGITS -------------...

  • [JAVA/chapter 7] Assignment: Write a program to process scores for a set of students. Arrays and...

    [JAVA/chapter 7] Assignment: Write a program to process scores for a set of students. Arrays and methods must be used for this program. Process: •Read the number of students in a class. Make sure that the user enters 1 or more students. •Create an array with the number of students entered by the user. •Then, read the name and the test score for each student. •Calculate the best or highest score. •Then, Calculate letter grades based on the following criteria:...

  • codeblock c++ language Write a program that reads students test scores in the range 0-200 from...

    codeblock c++ language Write a program that reads students test scores in the range 0-200 from a file until end of file (use e of() to check if ifstream reaches the End of File Stream) and store those scores in an array. It should then determine the number of students having scores in each of the following ranges: 0-24, 25-49, 50-74, 75-99, 100- 124, 125–149, 150-174, and 175–200. Finally, the program outputs the total number of students, each score range...

  • JAVA: (15 marks) Write a program that creates an integer array with 50 random values, prompts...

    JAVA: (15 marks) Write a program that creates an integer array with 50 random values, prompts the user to enter the index of an element in the array between 0 and 49, then displays the corresponding element value. If the specified index is out of bounds, display an error message (e.g. "Out of Bounds") and ask the user to enter another index. Use a while loop that will keep prompting the user until a valid input is received. To handle...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT