0% found this document useful (0 votes)
9 views3 pages

Solution

The document contains a Java program that prompts the user for a student's name, grade level, and grades in math, science, and Filipino, then calculates and displays the average grade. It also includes a separate function to calculate the volume of a sphere based on user-provided radius input. The program utilizes the Scanner class for input and includes error handling for invalid radius input.

Uploaded by

ventura.junel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views3 pages

Solution

The document contains a Java program that prompts the user for a student's name, grade level, and grades in math, science, and Filipino, then calculates and displays the average grade. It also includes a separate function to calculate the volume of a sphere based on user-provided radius input. The program utilizes the Scanner class for input and includes error handling for invalid radius input.

Uploaded by

ventura.junel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

import [Link].

Scanner;

public class Main {

public static void main(String[] args) {

Scanner scanner = new Scanner([Link]);

// Prompt and read student name

[Link]("Enter Student Name: ");

String studentName = [Link]();

// Prompt and read grade level

[Link]("Enter Grade Level: ");

int gradeLevel = [Link]();

// Prompt and read math grade

[Link]("Enter Math Grade: ");

float mathGrade = [Link]();

// Prompt and read science grade

[Link]("Enter Science Grade: ");

float scienceGrade = [Link]();

// Prompt and read Filipino grade

[Link]("Enter Filipino Grade: ");

float filipinoGrade = [Link]();

// Close scanner

[Link]();

// Display student report

displayStudentReport(studentName, gradeLevel, mathGrade, scienceGrade, filipinoGrade);

}
// Minimum requirement: public static float calculateAverage(float, float, float)

public static float calculateAverage(float math, float science, float filipino) {

return (math + science + filipino) / 3.0f;

// Minimum requirement: public static void displayStudentReport(String, int, float, float,


float)

public static void displayStudentReport(String name, int gradeLevel, float mathGrade, float
scienceGrade, float filipinoGrade) {

// Print student report details

[Link]("Student Name: " + name);

[Link]("Math Grade: %.2f%n", mathGrade);

[Link]("Science Grade: %.2f%n", scienceGrade);

[Link]("Filipino Grade: %.2f%n", filipinoGrade);

float averageGrade = calculateAverage(mathGrade, scienceGrade, filipinoGrade);

[Link]("Average Grade: %.2f%n", averageGrade);

import [Link];

public class Main {

public static float calculateSphereVolume(float radius) {

float volume = (4f/3f) * (float)[Link] * (float)[Link](radius, 3);

return volume;

}
public static void main(String[] args) {

float radius, volume;

Scanner scanner = new Scanner([Link]);

[Link]("Enter the radius of the sphere: ");

if (![Link]()) {

[Link]("Invalid input");

return;

radius = [Link]();

volume = calculateSphereVolume(radius);

[Link]("The volume of the sphere is: %.2f", volume);

You might also like