sniperx
12-22-03, 01:36 PM
I only want to use one method " the main method" because i am not aware of creating other methods as yet. I am new to java and i only want to focus on creating this program using the main method alone. I have written the following code so far and i need to continue it in order to finish it. I would appreciate it if you help me continue it and if you want you can make adjustments where necessary, but the program must contain one method, ie "the main method".
I am working on writing a java code to run a program. The program must do the
following:
INPUT
* Read in from the keyboard a student number (an integer between 10000 and
99999).
* Read in from the keyboard a student's first and last name.
* Read in a degree course title.
* Read in the number of courses a student wants to enter his/her final
coursework and exam marks for: this will always be a whole number (an integer)
between 1 and 8.
* For each course, read in the final coursework mark, and the final exam mark
(these may be decimal - real numbers).
OUTPUT
The program should print out the student's details, as entered, and then:
* Calculate and display the student's average (mean) coursework mark.
* Calculate and display the student's average (mean) exam mark.
* Calculate and display the student's average overall mark: this is based on
taking 20% of the average coursework mark and adding it to 80% of the average
exam mark.
* Calculate a letter grade for the student, on the basis that 70 or above is
an A, 60 up to 70 is a B, 50 up to 60 is a C, 40 up to 50 is a D, and 35 up to
40 is an E.
I have written the following code so far but seem to be getting some problems.
Could you continue writing out the code for me without changing anything that I
have written so far? Reason being that I am trying to only use one "method" to
write the code, which is the main method. I wrote the following so far:
import java.io.*;
class assessment
{
public static void main (String [] args) throws IOException
{
BufferedReader in=
new BufferedReader(new InputStreamReader(System.in));
String a, stuname, degtitle, b, c, ctitle, d;
int stunum, numcourse, cmark, fmark;
System.out.print("Enter Student Number: ");
a=in.readLine();
stunum=Integer.parseInt(a);
if ((stunum>=10000) && (stunum<=99999))
{
System.out.print("Enter Student's First and Last Name: ");
stuname=in.readLine();
System.out.print("Enter Degree Title: ");
degtitle=in.readLine();
System.out.print("Enter Number of Courses Applied For: ");
b=in.readLine();
numcourse=Integer.parseInt(b);
if ((numcourse>=1) && (numcourse<=8))
for (int i=0; i<numcourse; i++)
{
System.out.print("Enter Course Title: ");
ctitle=in.readLine();
System.out.print("Enter Course Mark for "+ctitle+" : ");
c=in.readLine();
cmark=Integer.parseInt(c);
if ((numcourse>=1) && (numcourse<=8))
System.out.print("Enter Final Exam Mark for "+ctitle+" : ");
d=in.readLine();
fmark=Integer.parseInt(d);
}
else
{
System.out.println("Maximum Number of Courses Applied for is 8");
}
}
else
{
System.out.println("Student Number Must be between 10000 and 99999");
}
stunum=0;
numcourse=0;
System.out.println("-------------------------------------------------------------------------------");
System.out.println(" F I N A L A S S E S S M E N T R E P O R T");
System.out.println("-------------------------------------------------------------------------------");
System.out.println();
System.out.println(" Student Number : "+stunum);
System.ou t.println(" Student Name : "+stuname);
System.out.println(" Degree Title : "+degtitle);
System.out.println(" Number of Courses Applied : "+numcourse);
System.out.println();
}
}
I am working on writing a java code to run a program. The program must do the
following:
INPUT
* Read in from the keyboard a student number (an integer between 10000 and
99999).
* Read in from the keyboard a student's first and last name.
* Read in a degree course title.
* Read in the number of courses a student wants to enter his/her final
coursework and exam marks for: this will always be a whole number (an integer)
between 1 and 8.
* For each course, read in the final coursework mark, and the final exam mark
(these may be decimal - real numbers).
OUTPUT
The program should print out the student's details, as entered, and then:
* Calculate and display the student's average (mean) coursework mark.
* Calculate and display the student's average (mean) exam mark.
* Calculate and display the student's average overall mark: this is based on
taking 20% of the average coursework mark and adding it to 80% of the average
exam mark.
* Calculate a letter grade for the student, on the basis that 70 or above is
an A, 60 up to 70 is a B, 50 up to 60 is a C, 40 up to 50 is a D, and 35 up to
40 is an E.
I have written the following code so far but seem to be getting some problems.
Could you continue writing out the code for me without changing anything that I
have written so far? Reason being that I am trying to only use one "method" to
write the code, which is the main method. I wrote the following so far:
import java.io.*;
class assessment
{
public static void main (String [] args) throws IOException
{
BufferedReader in=
new BufferedReader(new InputStreamReader(System.in));
String a, stuname, degtitle, b, c, ctitle, d;
int stunum, numcourse, cmark, fmark;
System.out.print("Enter Student Number: ");
a=in.readLine();
stunum=Integer.parseInt(a);
if ((stunum>=10000) && (stunum<=99999))
{
System.out.print("Enter Student's First and Last Name: ");
stuname=in.readLine();
System.out.print("Enter Degree Title: ");
degtitle=in.readLine();
System.out.print("Enter Number of Courses Applied For: ");
b=in.readLine();
numcourse=Integer.parseInt(b);
if ((numcourse>=1) && (numcourse<=8))
for (int i=0; i<numcourse; i++)
{
System.out.print("Enter Course Title: ");
ctitle=in.readLine();
System.out.print("Enter Course Mark for "+ctitle+" : ");
c=in.readLine();
cmark=Integer.parseInt(c);
if ((numcourse>=1) && (numcourse<=8))
System.out.print("Enter Final Exam Mark for "+ctitle+" : ");
d=in.readLine();
fmark=Integer.parseInt(d);
}
else
{
System.out.println("Maximum Number of Courses Applied for is 8");
}
}
else
{
System.out.println("Student Number Must be between 10000 and 99999");
}
stunum=0;
numcourse=0;
System.out.println("-------------------------------------------------------------------------------");
System.out.println(" F I N A L A S S E S S M E N T R E P O R T");
System.out.println("-------------------------------------------------------------------------------");
System.out.println();
System.out.println(" Student Number : "+stunum);
System.ou t.println(" Student Name : "+stuname);
System.out.println(" Degree Title : "+degtitle);
System.out.println(" Number of Courses Applied : "+numcourse);
System.out.println();
}
}