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(System.in);
Scanner inStr = new Scanner(System.in);
for(int i=1;(!found);i++)
{
System.out.print("Trainee Number: ");
tNum=in.nextInt();
if ((tNum<=1000) || (tNum>=9999))
System.out.println("Invalid Number - Please re-enter ");
else
found=true;
}
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)+": ");
tNum=in.nextInt();
if ((tNum<=1) || (tNum>=100))
System.out.println("invalid Quiz mark, please re-enter a valid quiz mark not above 100");
else
found=true;
quizMark[k]=in.nextDouble();
}
System.out.print("Final Module Test mark: ");
finalModule = in.nextDouble();
System.out.print("Another [Y/N]?");
ans=in.nextLine();
if(ans=="Y")vinto=true;
else
vinto=false;
{
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
- Data Science
- Android
- AJAX
- ASP.net
- C
- C++
- C#
- Cocoa
- Cloud Computing
- HTML5
- Java
- Javascript
- JSF
- JSP
- J2ME
- Java Beans
- EJB
- JDBC
- Linux
- Mac OS X
- iPhone
- MySQL
- Office 365
- Perl
- PHP
- Python
- Ruby
- VB.net
- Hibernate
- Struts
- SAP
- Trends
- Tech Reviews
- WebServices
- XML
- Certification
- Interview
categories
Related Tutorials
Java program to get location meta data from an image
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
Count number of vowels, consonants and digits in a String in Java
Student marks calculation program in Java
Calculate gross salary in Java
Calculate average sale of the week in Java
Vector in Java - Sample Program
Archived Comments
1. I changed import javax.comm.*; for this line impo
View Tutorial By: Julen at 2010-07-18 18:39:25
2. works too with deepnet security platform as to imp
View Tutorial By: biloute at 2013-05-29 11:04:51
3. hi friends i hav project work in this topic so pls
View Tutorial By: sullan at 2011-05-08 12:08:56
4. I want to store the Data in Vector or the LinkedLi
View Tutorial By: Sobia at 2013-01-17 11:24:59
5. hi.I am new in j2me and really want to learn more
View Tutorial By: vinoth kumar. A at 2012-10-26 05:20:31
6. You have to the point codes
View Tutorial By: workneh yilma at 2009-01-21 02:29:21
7. Hi,Please send me running code for sending sms fro
View Tutorial By: rahul at 2008-11-14 05:15:02
8. /** Example shows garbage collector in action
View Tutorial By: sreekar at 2010-05-08 07:58:09
9. class Factorial
{
int fact(int
View Tutorial By: soph at 2013-02-06 06:49:07
10. neded defination in clear
View Tutorial By: venkat at 2011-07-04 06:31:19