Comment on Tutorial - How to use ArrayList in Java By Hong

Comment Added by : carl

Comment Added at : 2011-01-30 22:21:21

Comment on Tutorial : How to use ArrayList in Java By Hong
i want my program to allow more than one traineeâs marks to be entered, and then print the results for each trainee at the
end of the program, rather than after each traineeâs marks have been entered.i got stuck and need your help

import java.util.Scanner;
public class InstructionalModulesResult {
private static int firstint,intModuleQuizMark, noOfQuiz;
private static String lastString, fistString,stringMode;
private static double [] QuizMark;
static char letterGrade;
public static void main(String[] args) {
boolean vinto=true;
String ans;
int tNum=0, nOfQuiz;
double [] quizMark;
double finalModule, avgMark, sumMark=0, overallMark;
String famName, firName, instModule;
char markGrade;
boolean found=false;
Scanner in = new Scanner(;
Scanner inStr = new Scanner(;
for(int i=1;(!found);i++)
System.out.print("Trainee Number: ");
if ((tNum<=1000) || (tNum>=9999))
System.out.println("Invalid Number - Please re-enter ");
System.out.print("Family Name: ");
famName =inStr.nextLine();
System.out.print("First Name: ");
firName =inStr.nextLine();
System.out.print("Instruction Module: ");
instModule =inStr.nextLine();
System.out.print("How many quizes shall i calculate?: ");
nOfQuiz =in.nextInt();
quizMark = new double [nOfQuiz];
for(int k=0; k<nOfQuiz;k++)
System.out.print("Module Quiz mark "+(k+1)+": ");
if ((tNum<=1) || (tNum>=100))
System.out.println("invalid Quiz mark, please re-enter a valid quiz mark not above 100");
System.out.print("Final Module Test mark: ");
finalModule = in.nextDouble();

System.out.print("Another [Y/N]?");

for (int k=0; k<nOfQuiz; k++)
sumMark = sumMark + quizMark[k];
avgMark =(sumMark)/nOfQuiz;
overallMark = (avgMark*0.20)+(finalModule*0.80);
markGrade = grade(overallMark);
System.out.println("Results for " + firName+" "+famName);
System.out.println("Trainee Number " + tNum);
System.out.println("Module: " + instModule);
System.out.println("Average Module Quiz: " + avgMark +" Final Module Test: " + finalModule+ " Overall Mark: " +overallMark);
System.out.println("Letter Grade: " + markGrade);

private static char grade (double graded) {
if (graded>=70)
letterGrade = 'A';
else if (graded>=60)
letterGrade = 'B';
else if (graded>=50)
letterGrade = 'C';
else if (graded>=40)
letterGrade = 'D';
else if (graded<=39 )
letterGrade = 'E';
return letterGrade;


View Tutorial

Subscribe to Tutorials

Related Tutorials

Program using concept of byte long short and int in java

Update contents of a file within a jar file

Tomcat and httpd configured in port 8080 and 80

Java File

Java String

Count number of vowels, consonants and digits in a String in Java

Reverse a number in Java

Student marks calculation program in Java

Handling Fractions in Java

Calculate gross salary in Java

Calculate average sale of the week in Java

Vector in Java - Sample Program

MultiLevel Inheritance sample in Java

Multiple Inheritance sample in Java

Java program using Method Overriding

Archived Comments

1. Hi,
Its good but you can make it more bette

View Tutorial          By: vishakha sharma at 2010-12-15 06:14:52

2. Looks like when I uninstall an app it should be un
View Tutorial          By: Danila Piatov at 2011-05-18 12:03:53

3. you can use multiple switch statements depending o
View Tutorial          By: moshood at 2012-04-01 13:24:41

4. 510

View Tutorial          By: sky at 2010-07-17 06:54:46

5. hi thanks for your tutorial, but I can`t run your
View Tutorial          By: yashar at 2015-05-29 18:57:30

6. I am assuming you are using eclipse for your andro
View Tutorial          By: Ashley at 2011-07-18 00:34:04

7. One of the best
View Tutorial          By: Sudhir at 2009-12-22 01:45:28

8. This site is sufficient for learning the programmi
View Tutorial          By: Shaheryar Khlaid at 2011-07-25 20:36:01

9. Thanks a lot.
View Tutorial          By: Nirwana at 2009-04-24 05:17:10

10. The Given Programms are not suitable for "How
View Tutorial          By: Rams at 2009-01-27 01:36:16