Java

 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me



Go Back   Tutorialized ForumsWeb Design & DevelopmentJava

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Tutorialized Forums Sponsor:
  #1  
Old October 16th, 2010, 08:50 PM
Bewitched1 Bewitched1 is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Jul 2010
Posts: 2 Bewitched1 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 24 m 46 sec
Reputation Power: 0
Need help with 2d Array

Hi,
I am trying to code a 2D array to input 3 grades for 10 students.

I am not getting it.

<code>import java.util.Scanner;
import java.io.*;



public class Assign06_Cheshire{
public static void main(String[] args){


Scanner input=new Scanner(System.in);

int midTerm1=0;
int midTerm2=0;
int finalExam=0;

int[][]grades= new int[10][3];


System.out.println("Enter the 10 Midterm 1 grades: ");

for ( int i = 0; i < grades.length; i++){
for (int j = 0; j < grades.length ; j++){
grades[i][j]=input.nextInt();
System.out.println(" MidTerm Grade "+(i+1)+": ");

}


System.out.print("Enter the 10 Midterm 2 grades: ");
for ( i = 0; i < grades.length; i++){
for (int j= 0; j < grades.length; j++){

System.out.print("Midterm Grade "+(i+1)+": ");
grades[i][j]=input.nextInt();
}
}
System.out.print("Enter the 10 Final Exam grades: ");
for ( i = 0; i< grades.length; i++){
for (int j = 0;j < grades.length; j++){
System.out.print("Final Exam Grade "+(i+1)+": ");
grades[i][j]=input.nextInt();

}

//add together the midterm 1 midterm 2 and final exam
for ( i=0;i<10;i++){
grade[i]=midterm1[i]+midterm2[i]+finalExam[i];


//calculate min and max grade
int minGrade=grade[0];
int maxGrade=grade[0];
for (int i=1;i<10;i++)
{
if (minGrade>grade[i])
minGrade=grade[i];
if (maxGrade<grade[i])
maxGrade=grade[i];
}

}

//display min and max grade
System.out.println("The minimum grade is "+minGrade);
System.out.println("The maximum grade is "+maxGrade);
}
}

}

}

</code>

Reply With Quote
Reply

Viewing: Tutorialized ForumsWeb Design & DevelopmentJava > Need help with 2d Array


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.

© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap