Python 3 - Can someone show me how to do this? I dont know how to do the calcula
ID: 3857533 • Letter: P
Question
Python 3 - Can someone show me how to do this? I dont know how to do the calculations at all.
Write a program to calculate the letter grade for a course for a number of students. The grades are as follow:
3 10-point Quizzes 30% of final grade
2 100-point Midterm 40% of final grade
1 100-point Final 30% of final grade
I've prepared a text file with some students and grades. You will find this under "Python Files". Use this file and the program(s) I posted that show you how to read from files to write a program that will read these grades and calculate the final grade using the percentages above.
Use a function to do the actual calculation
******The data from the txt file is listed below.
Explanation / Answer
This is the progrm
========================
class Testy
{
byte score;
Testy()
{
score=78;
}
public static void main(String arg[])
{
Testy tst=new Testy();
tst.processGrades();
}
public void processGrades()
{
if
(score >=75)
{
System.out.println("Your grade is A");
}
else
if
((score >= 60)&&( score <75 ))
{
System.out.println("Your grade is B");
}
if
((score >=50 )&&(score<60))
{
System.out.println("Your grade is C");
}
else
if
((score >=40 )&&(score <50))
{
System.out.println(" Your grade is D");
}
else
if
(score <40 )
{
System.out.println(" Sorry you have no part here,FAILED");
}
}
}
==============================
This program also shows grades in terms of
import java.util.Scanner;
public class CaseGrade {
public static void main(String[] args) {
Scanner input = new Scanner (System.in);
String name ;
int grade;
String exellent = "Exellent :";
String veryGgood ="Very Good :";
String good="Good :";
String pass ="Pass :";
String fail = "Fail :";
int max = 0;
int min = 100;
int sum = 0;
int avg ;
int counter =0;
boolean repeat ;
while (repeat =true)
{
System.out.println("Enter Name : ");
name = input.next();
System.out.println("Enter Grade : ");
grade = input.nextInt();
if (grade == -1 )
{
avg = sum / counter;
System.out.println(" result = :");
System.out.println(exellent +" "+ veryGgood +" "+ good +" "+ pass +" "+fail);
System.out.println("maximum = "+ max +" ");
System.out.println("minimum = "+ min +" ");
System.out.println(" Average = " +avg);
System.exit(0);
}
switch (grade/10)
{
case 100:
case 9 :
exellent += " "+ name + " " +grade+" ";
break;
case 8 :
veryGgood += " " + name + " " +grade +" ";
break ;
case 7 :
good += " " + name + " " +grade +" ";
break;
case 6:
case 5:
pass += " " + name + " " +grade +" ";
break;
default:
fail +=" " + name + " " +grade +" ";
break;
}
sum = sum + grade;
counter = counter + 1;
if (grade > max)
{
max = grade;
}
if (grade < min)
{
min = grade;
}
}
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.