Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

 
 
Thread Tools Display Modes
Prev Previous Post in Thread   Next Post in Thread Next
Old Mar 2nd, 2008, 8:32 PM   #1
kalli002
Newbie
 
Join Date: Mar 2008
Location: Sri lanka
Posts: 2
Rep Power: 0 kalli002 is on a distinguished road
Send a message via Skype™ to kalli002
Thumbs up hay

im very new to JAVA i goot an assignment to write a program that is
take 3 boxes and it has "n" number of eggs after each box done with the counting it have to print the totel of it and after all 3 done max total have to print so far i done as below
import java.util.*;
class egg3{
public static void main(String args[]){
Scanner input=new Scanner(System.in);
int x=1;
int total=0;
int t1=0;
for(int j=0;j<3;j++){
System.out.println("Box 00"+(j+1)+"");

while(x!=0){
System.out.print("Input egg wegiht ");
x=input.nextInt();
total=total+x;

}
System.out.println("Total wegiht of the box : "+total);
System.out.println();
t1=total+t1;
}

System.out.println("Grand Total :" +t1);
}
}
this can enter any number of valus as u can see when we give "0" i stopes and print total ,but it wont continu to other 2 as well

what shud i do ples explane
kalli002 is offline   Reply With Quote
 

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 11:35 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC