Create a program in Java that does the following: 1) Creates an array \"student_
ID: 673486 • Letter: C
Question
Create a program in Java that does the following:
1) Creates an array "student_gpa" of size 10 and contains the current GPA of 10 students (assume the GPA is in the range 0-4).
2) Computes the percentage of students that get scholarship because their GPA is at least 3.5
3) Computes the average GPA of all students.
4) Computes the average GPA of the students with scholarship.
5) Computes the average GPA of the students without scholarship.
REQUIREMENTS:
a) You must include a "for" loop in answering the parts 2,3,4,5
b) You must not create any additional array besides "student_gpa". You may create individual variables to store the answers of questions 2,3,4,5.
Explanation / Answer
import java.util.Scanner;
public class Scholarship
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
double highSchoolGPA;
int numberExtActivities;
int numberServActivities;
System.out.print("Enter student's high school GPA: ");
highSchoolGPA=input.nextDouble();
System.out.print("Enter student's number of extracurricular activities: ");
numberExtActivities=input.nextInt();
System.out.print("Enter student's number of service activities: ");
numberServActivities=input.nextInt();
System.out.println(" Input Summary");
System.out.println("--------------");
System.out.println("GPA: "+highSchoolGPA);
System.out.println("Extracurricular Activities: "+numberExtActivities);
System.out.println("Service Activities: "+numberServActivities+" ");
//A GPA of 3.8 or above and at least 1 extracurricular activity and at least 1 service activity
if ((highSchoolGPA>=3.8 && highSchoolGPA<=4.0) && numberExtActivities>=1 && numberServActivities>=1)
{
System.out.println("Scholarship candidate! :) [Tier1]");
}
//A GPA of at least 3.4 but less than 3.8 and at least 3 extracurricular and service activities
else if ((highSchoolGPA>=3.4 && highSchoolGPA<3.8) && ((numberExtActivities+numberServActivities)>=3))
{
System.out.println("Scholarship candidate2! :) [Tier2]");
}
//A GPA of at least 3.0 but less than 3.4 and at least 2 extracurricular activities and 3 service activities
else if ((highSchoolGPA>=3.0 && highSchoolGPA<3.4) && (numberExtActivities>=2) && (numberServActivities>=3))
{
System.out.println("Scholarship candidate3! :) [Tier3]");
}
else if (highSchoolGPA<0.0 || highSchoolGPA>4.0 || numberExtActivities<0 || numberServActivities<0)
{
System.out.println("Input Error! >:[");
}
else
{
System.out.println("Not a candidate. :(");
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.