p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

beginning_java thread: Re: Getting input from keyboard?


Message #1 by "Ivor Horton" <ivor.horton@b...> on Mon, 22 Apr 2002 11:25:07 +0100
Reading input from the keyboard is discussed on P378. The reason it is so
far into the book is that you need to understand classes to do it.
Ivor



Message #2 by "naveedm" <naveedm@e...> on Mon, 22 Apr 2002 13:13:10 +0500
Hello Ketut Parikesit,
				here I give u a simple program of grade
test in which you can give input at run time.
I hope it will help u
import java.io.*;

class GradeTest 
{
 public static void main(String args[]) throws IOException
{
	//declare variables

	double per;
	int java;
	int oop;
	int rdbms;
	String num1,num2,num3;
	int opt;
	
	//create object and initialize it
	
	BufferedReader br=new BufferedReader(new
InputStreamReader(System.in));
	while(true)	
	{
	 
	\\ask user input
	 
	System.out.println("Enter Your java Marks______::");
	
		
	num1=br.readLine(); 
	
	java =Integer.parseInt(num1);
	
	System.out.println("Enter Your OOPS Marks______::");	
	
		
	num2=br.readLine();
	
	oop  =Integer.parseInt(num2);	


	System.out.println("Enter Your RDBMS Marks_____::");	

		
	num3=br.readLine();

	rdbms=Integer.parseInt(num3);
	

	if (java>100||rdbms>100||oop>100)
	 
	   {
	    System.out.println("You enter wrong number please again
enter::");  
	    
	   }	
	  
	if (java<=100&&rdbms<=100&&oop<=100)
	
	{
	per=((java+oop+rdbms)/300.0)*100.0;
	
	if (per>=90)
	
 	System.out.println("Excelent Your overall percentage is
"+per+"%");
	
	if (per>=80&&per<=89)
	
	System.out.println("Very Good Your overall percentage is
"+per+"%");
	
	if (per>=70&&per<=79)
	
	System.out.println(" Good Your overall percentage is "+per+"%");
	
	if (per>=60&&per<=69)
	
	System.out.println("Satisfactory Your overall percentage is
"+per+"%");
	
	if (per<59)
	
	System.out.println("Please work hard Your overall percentage is
"+per+"%");
	
	if (java>=90&&java<=100)

	   System.out.println("In JAVA you get A Grade");
	
	if (java>=80&&java<=89)
	
	   System.out.println("In JAVA you get B Grade");	   

	if (java>=70&&java<=79)

	   System.out.println("In JAVA you get C Grade");

	if (java>=60&&java<=69)

	   System.out.println("In JAVA you get D Grade");

	if (java<=59)

	   System.out.println("You are Fail in JAVA");

	if (oop>=90&&oop<=100)

	   System.out.println("In OOP you get A Grade");
	
	if (oop>=80&&oop<=89)
	
	   System.out.println("In OOP you get B Grade");	   

	if (oop>=70&&oop<=79)

	   System.out.println("In OOP you get C Grade");

	if (oop>=60&&oop<=69)

	   System.out.println("In OOP you get D Grade");

	if (oop<=59)

	   System.out.println("You are Fail in OOP");
	
	if (rdbms>=90&&rdbms<=100)

	   System.out.println("In RDBMS you get A Grade");
	
	if (rdbms>=80&&rdbms<=89)
	
	   System.out.println("In RDBMS you get B Grade");	   

	if (rdbms>=70&&rdbms<=79)

	   System.out.println("In RDBMS you get C Grade");

	if (rdbms>=60&&rdbms<=69)

	   System.out.println("In RDBMS you get D Grade");

	if (rdbms<=59)

	   System.out.println("You are Fail in RDBMS");
	
	
	break;
	}	

	
	}
}

}
Regards
Naveed
-----Original Message-----
From: I Ketut Parikesit [mailto:nyenkaden@y...] 
Sent: Monday, April 22, 2002 6:03 AM
To: Beginning Java
Subject: [beginning_java] Getting input from keyboard?


Hi, greetings from Bali.
I'm very new here, and also very new with Java. I just started Ivor's
book 
(Beginning Java 2) and still using 1.3, haven't downloaded 1.4 yet.

At the moment I'm in the middle of chapter 2, and have tried the 'fruity

program'. I have one question now.

The program introduces the method to print the output of into the
screen. 
But what method should I use if I want the program to ask the user to
give 
it an input? Say, for instance, the program asks the user how many
oranges 
and how many apples he has, and then the program calculates the total 
number of fruits.

In what chapter does it explained in the book? I tried the index but 
couldn't find it.

Thank you
---
Do you need true END-TO-END (e2e) Java Messaging (JMS)?  Softwired
offers industry's ONLY complete 100% JMS messaging solutions for your
needs TODAY. Visit
http://adtracking.wrox.com/track.asp?x=p2p%2Fe%2Fjava%2Dsoftwired&url=ww
w.softwired-inc.com Our unique product range includes: iBus//Mobile
(wireless data), iBus//MessageBus (IP Multicast), iBus//MessageServer
(store and forward) and much more!


=======================================================
This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom
they are addressed. If you have received this email in error, please notify the sender or the System Administrator at
esbi.rousch@e... .The unauthorized use, disclosure or alteration of this message is strictly forbidden. Moreover, this
message has been scanned for the presence of computer viruses.

Message #3 by "I Ketut Parikesit" <nyenkaden@y...> on Mon, 22 Apr 2002 06:02:51
Hi, greetings from Bali.
I'm very new here, and also very new with Java. I just started Ivor's book 
(Beginning Java 2) and still using 1.3, haven't downloaded 1.4 yet.

At the moment I'm in the middle of chapter 2, and have tried the 'fruity 
program'. I have one question now.

The program introduces the method to print the output of into the screen. 
But what method should I use if I want the program to ask the user to give 
it an input? Say, for instance, the program asks the user how many oranges 
and how many apples he has, and then the program calculates the total 
number of fruits.

In what chapter does it explained in the book? I tried the index but 
couldn't find it.

Thank you

  Return to Index