The Artima Developer Community
Sponsored Link

Java Answers Forum
Java beginner

3 replies on 1 page. Most recent reply: Feb 6, 2006 1:47 AM by Matthias Neumair

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 3 replies on 1 page
Marlon Cortez

Posts: 7
Nickname: cotz
Registered: Feb, 2006

Java beginner Posted: Feb 2, 2006 8:33 PM
Reply to this message Reply
Advertisement
public class IfElseDemo {
public static void main(String[] args) {

int testscore = 76;
char grade;

if (testscore >= 90) {
grade = 'A';
} else if (testscore >= 80) {
grade = 'B';
} else if (testscore >= 70) {
grade = 'C';
} else if (testscore >= 60) {
grade = 'D';
} else {
grade = 'F';
}
System.out.println("Grade = " + grade);
}
}
This is the output from the program.
Grade = C

what if.. i want to put myself a testscore and not by default as it was in above testscore = 76;... how change it?
tnx


Matthias Neumair

Posts: 660
Nickname: neumi
Registered: Sep, 2003

Re: Java beginner Posted: Feb 2, 2006 11:33 PM
Reply to this message Reply
I think System.in.read() is what you are looking for.

Marlon Cortez

Posts: 7
Nickname: cotz
Registered: Feb, 2006

Re: Java beginner Posted: Feb 3, 2006 11:04 PM
Reply to this message Reply
System.in.read()?

ok i'll try this one...tnx..

how to change the format of this?

just want to know how ?

Matthias Neumair

Posts: 660
Nickname: neumi
Registered: Sep, 2003

Re: Java beginner Posted: Feb 6, 2006 1:47 AM
Reply to this message Reply
Of course I know how.

But I don't do you homework for you.

Did you even read the API documentation of System.in.read() before asking that question?

Flat View: This topic has 3 replies on 1 page
Topic: Help Previous Topic   Next Topic Topic: how to program this?

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use