JavaSpace
Would you like to react to this message? Create an account in a few clicks or log in to continue.

JavaSpace

JavaSpace is a forum were people can help others learn java. Also a place for tutorials. We do everything java!
 
HomePortalSearchLatest imagesRegisterLog in

 

 [TuT Source code] - if else statements

Go down 
AuthorMessage
JavaClaDZ
Admin
JavaClaDZ


Posts : 18
Join date : 2008-02-23
Age : 33

[TuT Source code] - if else statements Empty
PostSubject: [TuT Source code] - if else statements   [TuT Source code] - if else statements Icon_minitimeSat Apr 05, 2008 7:04 am

Ok so a big thing is Java is if else statements. king
some symbols you need to know
Code:
== means is equal to
>= means greater than or equal to
<= means less than or equal to
! means not
!=  means not equal to
|| means or
&& means and

So this is a source code I made to a simple program that uses if else statements. Its based of grades and shows the basics.

Code:
import java.util.*;
/**
 * A simple program that shows you if else statements
 *
 * @author (JavaCladz from Javaspace.darkbb.com)
 * @version (1)
 */
public class if_else
{
    public static void main(String[] args)
    {
  double percent = 0.0;
  char grade;
 
  Scanner scan = new Scanner(System.in);
 
  System.out.print("What percent did you get: ");
    percent = scan.nextDouble();
 
  if(percent >= 90.0)
  {
      grade = 'A';
    }
  else if(percent >= 80.0)
  {
      grade = 'B';
    }
  else if(percent >= 70.0)
  {
      grade = 'C';
    }
  else if(percent >= 60.0)
  {
      grade = 'D';
    }
  else
  {
      grade = 'E';
    }
 
  System.out.print("\n Your grade is:" + grade);
  }
}
Back to top Go down
https://javaspace.board-directory.net
 
[TuT Source code] - if else statements
Back to top 
Page 1 of 1
 Similar topics
-
» [TuT- Source Code] Screen Capture Program
» [Tut-Source code]-very easy swing into{Hello from JavaSpace

Permissions in this forum:You cannot reply to topics in this forum
JavaSpace :: JavaTutorial Index :: Tutorials-
Jump to: