Java_Practice_Questions_and_Solutions_Corrected
Java_Practice_Questions_and_Solutions_Corrected
1. Grade Calculator
-------------------
Logic: Take the user's marks, check which range they fall into, and print the appropriate grade using
if-else conditions.
Code:
import java.util.Scanner;
System.out.println("Grade: A");
System.out.println("Grade: B");
System.out.println("Grade: C");
System.out.println("Grade: D");
} else {
System.out.println("Grade: F");
}
------------------------
Logic: Loop through 10 numbers, use num % 2 to check if even or odd, and keep count.
Code:
import java.util.Scanner;
if (num % 2 == 0) {
evenCount++;
} else {
oddCount++;
... (Truncated for brevity, but follows the same structure for other solutions.)