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

Assignment No 1

Uploaded by

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

Assignment No 1

Uploaded by

shawaizahmed010
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Assignment no 1

By

SHAWAIZ AHMED (4598-BSCS-F22-B)

SUBMITTED TO: SIR Syed Saqlain Hassan


SUBJECT: Advance Computer Programming
Date: 18/10/2024

DEPARTMENT OF COMPUTER SCIENCE


ISLAMIC INTERNATIONAL UNIVERSITY
ISLAMABAD
Answers

Answer # 1
 Code:
//By Shawaiz Ahmed (4598):
import javax.swing.JOptionPane;

public class studentGrades {

// Method to calculate grade based on score


public static String calculateGrade(int score) {
if (score >= 90 && score <= 100) {
return "A";
} else if (score >= 80 && score < 90) {
return "B";
} else if (score >= 70 && score < 80) {
return "C";
} else if (score >= 60 && score < 70) {
return "D";
} else if (score >= 0 && score < 60) {
return "F";
} else {
return "Invalid Score";
}
}

public static void main(String[] args) {


// Input number of students
String numStudentsInput = JOptionPane.showInputDialog("Enter the number
of students:");
int numStudents = Integer.parseInt(numStudentsInput);

for (int i = 0; i < numStudents; i++) {


String scoreInput = JOptionPane.showInputDialog("Enter the score for
student " + (i + 1) + ": ");
int score = Integer.parseInt(scoreInput);

// Calculate and display the grade


String grade = calculateGrade(score);
JOptionPane.showMessageDialog(null, "Grade for student " + (i + 1) +
": " + grade);
}
}
}

 Output Screen:

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy