State and explain four features of java programming language (4 Marks)d) Write a Java program that determines a student’s grade. The program will read three types ofscores(quiz, mid-term, and final scores) and determine the grade based on the following rules: -if theaverage score >=90% =>grade=A -if the average score >= 70% and <90% => grade=B -if theaverage score>=50% and <70% =>grade=C -if the average score<50% =>grade=F(7 Marks)
Question
State and explain four features of java programming language (4 Marks)d) Write a Java program that determines a student’s grade. The program will read three types ofscores(quiz, mid-term, and final scores) and determine the grade based on the following rules: -if theaverage score >=90% =>grade=A -if the average score >= 70% and <90% => grade=B -if theaverage score>=50% and <70% =>grade=C -if the average score<50% =>grade=F(7 Marks)
Solution
a) Features of Java Programming Language:
-
Object-Oriented: Everything in Java is an object. Java can be easily extended as it is based on the Object model.
-
Platform Independent: Unlike other programming languages such as C, C++ etc which are compiled into platform specific machines. Java is guaranteed to be write-once, run-anywhere language.
-
Simple: Java is designed to be easy to learn. If you understand the basic concept of OOP, Java would be easy to master.
-
Secure: With Java's secure feature, it enables to develop virus-free, tamper-free systems. Authentication techniques are based on public-key encryption.
b) Java program to determine a student's grade:
import java.util.Scanner;
public class StudentGrade {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("Enter quiz score: ");
double quizScore = input.nextDouble();
System.out.println("Enter mid-term score: ");
double midTermScore = input.nextDouble();
System.out.println("Enter final score: ");
double finalScore = input.nextDouble();
double averageScore = (quizScore + midTermScore + finalScore) / 3;
if (averageScore >= 90) {
System.out.println("Grade = A");
} else if (averageScore >= 70 && averageScore < 90) {
System.out.println("Grade = B");
} else if (averageScore >= 50 && averageScore < 70) {
System.out.println("Grade = C");
} else if (averageScore < 50) {
System.out.println("Grade = F");
}
}
}
This program first takes the quiz, mid-term, and final scores as input from the user. It then calculates the average score and determines the grade based on the given conditions.
Similar Questions
Check the following Java program carefully. What should be written in the blank? Choose from the given options. public class Test { public static void main(String[] args) { System.out.print("The grade is " + getGrade(78.5)); System.out.print("\nThe grade is " + getGrade(59.5)); } public static ________ getGrade(double score) { if (score >= 90.0) return 'A'; else if (score >= 80.0) return 'B'; else if (score >= 70.0) return 'C'; else if (score >= 60.0) return 'D'; else return 'F'; }}Group of answer choicesvoidStringintchar
using the while loop, and scenner draft a java code that grades students when they enter makes it grades it with A,B+,B,C,C+ and F grades
Java Program To Accept the Marks of a Student and Find the Total Marks and Percentage
Problem StatementA computer science teacher assigned the students a programming task that calculates and displays grades based on test marks. The teacher wants the program to take a student's test mark as input and determine their grade using the following criteria:If the mark is between 90 and 100 (inclusive), assign grade A.If the mark is between 80 and 89 (inclusive), assign grade B.If the mark is between 70 and 79 (inclusive), assign grade C.If the mark is between 60 and 69 (inclusive), assign grade D.If the mark is between 45 and 59 (inclusive), assign grade E.For marks below 45 assign grade F.If the mark is greater than 100 or a negative number, it displays "Invalid input". Help the students to accomplish the given task.Note: This question helps in clearing AMCAT exam.Input format :The input consists of a single integer, representing the student's mark.Output format :The output displays "Grade: " followed by the grade for the given mark based on the given criteria.If the mark is greater than 100 or a negative number, the output displays "Invalid input".Refer to the sample output for the formatting specifications.Code constraints :In the given scenario, the test cases fall under the following constraints:0 ≤ student's mark ≤ 100Sample test cases :Input 1 :100Output 1 :Grade: AInput 2 :85Output 2 :Grade: BInput 3 :79Output 3 :Grade: CInput 4 :63Output 4 :Grade: DInput 5 :56Output 5 :Grade: EInput 6 :0Output 6 :Grade: FInput 7 :-5Output 7 :Invalid inputInput 8 :126Output 8 :Invalid input
Code 1 Copy this code, compile and run it so you can answer the questions. import java.util.Scanner; public class UserGradingSystem { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); // Prompt user to enter scores for three subjects System.out.print("Enter math score: "); int mathScore = scanner.nextInt(); System.out.print("Enter science score: "); int scienceScore = scanner.nextInt(); System.out.print("Enter English score: "); int englishScore = scanner.nextInt(); // Calculate the average score int averageScore = (mathScore + scienceScore + englishScore) / 3; // Determine the overall grade if (averageScore >= 90) { System.out.println("Outstanding!"); } else if (averageScore >= 80) { System.out.println("Very Good!"); } else if (averageScore >= 70) { System.out.println("Good"); } else { System.out.println("Needs improvement"); } } } What if the user enters "85," "90," and "88," but mistakenly adds a semicolon after the English score, entering "88;"? (Refer to Code 1) Group of answer choices The program outputs "Needs improvement" for the invalid score. The program handles it gracefully, treating the input as valid. The program outputs "Outstanding!" for the valid scores. The program crashes with a runtime exception.
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.