# Need help with program!!

• 02-14-2013, 03:57 AM
snewman8771
Need help with program!!
Hi I am seth. New to programming. Ok so I am supposed to make a program that will take ONLY 5 grades, compute the final grade
PERCENTAGE of a student, and return it. However, each individual letter grade will be converted to a
numerical value. I am using two different classes. If you guys could help me out with where I proceed after this it would be much appreciated. Here is what I have so far.

The Constructor Class

public class LabStudent
{
private String NameOfStudent;

double avg;
public LabStudent(String name, String grades)
{
NameOfStudent = name;

}
public double calculateAverage(String grades)
{
double sum=0;

for(int i = 0; i < grades.length(); i++)
{
//sum = sum + leter
}

return avg;

// for loop // iterate through the grades string
// sum += letterToPercent(grades.charAt(i))

// avg = sum / grades.length();

}
public double letterToPercent(char letterGrade)
{
return 100;
{
return 80;
}
{
return 70;
}
{
return 65;
}
else return 0;
}
//public double letterToPercent()
//{

//}
public char PercenttoLetter(double percent)
{
if(percent >=90) //&& percent <=100)
return 'A';
else if(percent >90 && percent <=80)
{
return 'B';
}
else if(percent >80 && percent<=70)
{
return 'C';
}
else if(percent >=70 && percent <= 60)
{
return 'D';
}
else return 'F';
}
public String toString()
{
return "Output:" + NameOfStudent + " " + avg;
}
}

The Driver Class
import java.util.Scanner;

public class ComputerLab
{
public static void main(String [] args)
{
enterStudents();
{
Scanner scan = new Scanner(System.in);
System.out.println("enter number of Students");
LabStudent s = new Student("Robert", "ABCDD");
LabStudent s1 = new Student("smith" , "ABDFC");
int N = scan.nextInt();

//for (int index, index < N, index++)
for (int i=0; i<N; i++)
{
String name = scan.next();
String grades = scan.next();
//LabStudent s = new LabStudent();
System.out.println("check " + name + " " + grades);
{ name=scan.next();

System.out.println("ERROR");
}
}
}

{

// System.out.println("Tracer 1 " + grades);
//System.out.println("Tracer 1 " + grades.length());

return true;
for( int i =0; i < grades.length(); i++)
{
return true;
}
return false;

}
}

I dont know where to procede after this. As well as How to make it runnable.
If yall could help me it would be appreciated. Thanks
Also the part I put in comments I am not sure if It will run with it.
• 02-14-2013, 10:19 AM
DarrylBurke
Re: Need help with program!!
Please go through the Forum Rules, particularly the third paragraph. Also go through http://www.java-forums.org/forum-gui...w-members.html and BB Code List - Java Programming Forum - Learn Java Programming and edit your post accordingly.

To change the subject line, click 'Edit Post' and then 'Go Advanced'

db
• 02-14-2013, 06:40 PM
harshit shah
Re: Need help with program!!
Please wrap code tags around your code.
what is
Quote:

enterStudents();
in your driver class.If it is a method to be called,I do not find it anywhere in your code.
all the // statements will not be interpreted by the jvm.
• 02-15-2013, 02:17 AM
Wizard0860
Re: Need help with program!!
create a joptionpanel. create 5 boxes. parse int/double those to lets say int a,b,c,d,e. get average into int x. if(x==(insert array here, might not work tho not sure, for ex:83-86(in array))) System.out.println("B"). just do that for rest.
• 02-15-2013, 06:06 AM
DarrylBurke
Re: Need help with program!!
Quote:

Originally Posted by Wizard0860
create a joptionpanel.

A what?

db
• 02-15-2013, 02:10 PM
Wizard0860
Re: Need help with program!!
• 02-15-2013, 02:37 PM
Tolls
Re: Need help with program!!
First off, they have a Scanner and seem happy reading from the console.
Second Java is case sensitive.