this assignment here was my take home assignment. I am kinda doing it over just to see and know where i went wrong with. it is either my codes wrong somewhere but am not getting the required output.
I had to do two methods along with two arrays. dont know if my arrays were correctly done bcuz the output am getting is not what it was supposed to be:
here is an example hw the program should have run:
enter the student name: marcus smith
enter student id: 00012541
enter the academic year: 2015
enter the semester no: 2
enter the number of courses did in the above semester: 3
student: marcus smith
student id: 00012541
academic year:2015
semester no: 2
courses pursed
itec 125
grade: a
gpa: 3.5
here is my codes and the output.ublic static int calGpa(int grdevalpt, int qpts){
double grdeval;
String usergrde;
if("usergrde".equals("A"))
grdeval = (4 * 3);
else if("usergrde".equals("B+"))
grdeval = (3.5 * 3);
else if("usergrde".equals("B"))
grdeval = (3.0 * 3);
else if("usergrde".equals("C+"))
grdeval = (2.5 * 3);
else if("usergrde".equals("C"))
grdeval = (2 * 3);
else if("usergrde".equals("D+"))
grdeval = (1.5 * 5);
else if("usergrde".equals("D"))
grdeval = (1 * 3);
else if("usergrde".equals("F"))
grdeval = (0 * 3);
else
System.out.println("you are academic probation");
return qpts;
}
public static void main(String[] args)
{
Scanner putin = new Scanner(System.in);
int grderec = 0, gpa = 0;
int credhrs =0, tqpts =0, grde;
double cqpts;
double calQualityPoints;
int grdeval = 0, qpts = 0;
System.out.println("Hi please enter your id number");
int stidnum = putin.nextInt();
System.out.println("Hi what is your name");
String username = putin.next();
System.out.println("Hi please enter the academic year");
int acyr = putin.nextInt();
System.out.println("Hi which semester did you register for");
int semno = putin.nextInt();
System.out.println("Hi how many course did you take");
int numcourses = putin.nextInt();
System.out.println("***********************************************");
System.out.println("Hi what is your course code");
String coursecde = putin.next();
System.out.println("Hi how much is your course credit");
int coursecred = putin.nextInt();
System.out.println("Hi what is the grade code you recieved in the course taken");
int grdecde = putin.nextInt();
System.out.println("********************************************");
cqpts = calQualityPoint(tqpts, credhrs);
gpa = calGpa(grdeval,qpts);
int[] grades = new int[3];
grades[0]= 'A';
grades[1]= 'B';
grades[2]= 'B';
for(int i = 1; i<3; i++)
{
System.out.println("enter the students grades");
String grade = putin.nextLine();
System.out.println("the student grade is " + grades[0]);
System.out.println("the student grade is " + grades[1]);
System.out.println("the student grade is " + grades[2]);
}
String[]courses = new String[3];
courses[0]= "ITEC 133";
courses[1]= "ITEC 224";
courses[2]= "ITEC 121";
for(int i = 1; i<3; i++)
{
System.out.println("enter the student courses");
String usercourses = putin.nextLine();
System.out.println("the student courses are " + courses[0]);
System.out.println("the student courses are " + courses[1]);
System.out.println("the student courses are " + courses[2]);
}
System.out.println("the student id number is " + stidnum);
System.out.println("the name of the student is " + username);
System.out.println("the semester number is " + semno);
System.out.println("the academic year is " + acyr);
System.out.println("the number of course done " + numcourses);
System.out.println("the grades recieved for each course are " + grderec);
System.out.println("the gpa recieve for the given semester is" + gpa);
and here is my output
run:
Hi please enter your id number
0002485
Hi what is your name
liselle
Hi please enter the academic year
2015
Hi which semester did you register for
2
Hi how many course did you take
3
***********************************************
Hi what is your course code
itec133
Hi how much is your course credit
3
Hi what is the grade code you recieved in the course taken
3
********************************************
you are academic probation
enter the students grades
the student grade is 65
the student grade is 66
the student grade is 66
enter the students grades
a
the student grade is 65
the student grade is 66
the student grade is 66
enter the student courses
itec133
the student courses are ITEC 133
the student courses are ITEC 224
the student courses are ITEC 121
enter the student courses
itec224
the student courses are ITEC 133
the student courses are ITEC 224
the student courses are ITEC 121
the student id number is 2485
the name of the student is liselle
the semester number is 2
the academic year is 2015
the number of course done 3
the grades recieved for each course are 0
the gpa recieve for the given semester is0
BUILD SUCCESSFUL (total time: 1 minute 19 seconds)
what is drastically wrong here
divinity02 6 Posting Whiz in Training
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
divinity02 6 Posting Whiz in Training
cgeier 187 Junior Poster
divinity02 6 Posting Whiz in Training
cgeier 187 Junior Poster
cgeier 187 Junior Poster
divinity02 6 Posting Whiz in Training
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.