what code I'll write?

Based on this statement what code should I write? this is just a attendance test "Macky is a fourth-year Information Technology student who is an aspirant Cum Laude. During his last term of schooling, he monitors his Midterm Grades taken from the seven subjects which have ratings of 95, 94, 97, 90, 93, 92, and 91. Your task is to create a program that will input Macky's ratings and display the smallest grade that he has. Be sure to use the correct inputs properly to satisfy the given condition." SAMPLE OUTPUT: Enter first grade: 95 Enter second grade: 94 Enter third grade: 97 Enter fourth grade: 90 Enter fifth grade: 93 Enter sixth grade: 92 Enter seventh grade: 91 The smallest grade is 90.
3 Replies
JavaBot
JavaBot2mo ago
This post has been reserved for your question.
Hey @Dosage! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
john
john2mo ago
import java.util.Scanner;
public class Grades {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int[] grades = new int[7];


System.out.print("Enter first grade: ");
grades[0] = scanner.nextInt();
System.out.print("Enter second grade: ");
grades[1] = scanner.nextInt();
System.out.print("Enter third grade: ");
grades[2] = scanner.nextInt();
System.out.print("Enter fourth grade: ");
grades[3] = scanner.nextInt();
System.out.print("Enter fifth grade: ");
grades[4] = scanner.nextInt();
System.out.print("Enter sixth grade: ");
grades[5] = scanner.nextInt();
System.out.print("Enter seventh grade: ");
grades[6] = scanner.nextInt();


int smallestGrade = grades[0];
for (int i = 1; i < grades.length; i++) {
if (grades[i] < smallestGrade) {
smallestGrade = grades[i];
}
}


System.out.println("The smallest grade is " + smallestGrade + ".");

scanner.close();
}
}
public class Grades {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int[] grades = new int[7];


System.out.print("Enter first grade: ");
grades[0] = scanner.nextInt();
System.out.print("Enter second grade: ");
grades[1] = scanner.nextInt();
System.out.print("Enter third grade: ");
grades[2] = scanner.nextInt();
System.out.print("Enter fourth grade: ");
grades[3] = scanner.nextInt();
System.out.print("Enter fifth grade: ");
grades[4] = scanner.nextInt();
System.out.print("Enter sixth grade: ");
grades[5] = scanner.nextInt();
System.out.print("Enter seventh grade: ");
grades[6] = scanner.nextInt();


int smallestGrade = grades[0];
for (int i = 1; i < grades.length; i++) {
if (grades[i] < smallestGrade) {
smallestGrade = grades[i];
}
}


System.out.println("The smallest grade is " + smallestGrade + ".");

scanner.close();
}
}
This message has been formatted automatically. You can disable this using /preferences.
JavaBot
JavaBot2mo ago
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.
Want results from more Discord servers?
Add your server