KidsLovePC Contact Us
  Home   PHP  Graphics ASP  JavaScript   J2EE  HTML  JAVA   Swing   Webtip  Forums  Lyric  Free sheet music  Ringtones

dish, directive installerNow, you know how to calculate. But you need tell me how to think. For example, if your daddy plan to buy car insurance and want your to decide which one is good, Progressive car insurance($400) or Allstate car insurace($256) or GEICO($350)?

You probably say "choose the lowest insurance". Correct! But you need know how to choose the lowest price in JAVA. That means how to compare those prices in JAVA

> true if left is greater than the right ,false otherwise
> = true if left is greater than or equal to the right, false otherwise
== true if left is equal to the right , false otherwise
!= true if left is not equal to the right false otherwise
< = true if left is less than or equal to the right ,false otherwise
< true if left is less than the right, false otherwise

if statement

if(expression)
statement;

Example
boolean isGradeA?;
if(Score>=90)
isGradeA=true;

if else statement

if(expression)
    statement;
else
    statement;

Example
boolean isGradeA?;
if(Score>=90)
   isGradeA=true;

else
    isGradeA=true;

Here is my code to find the lowest price in car insurance:

class car_insurance
{
public static void main(String[] args)
{
int ProgressivePrice=400;
int AllStatePrice=256;
int GEICOPrice=300;
int lowestPrice;
if(ProgressivePrice>AllStatePrice)
    lowestPrice=AllStatePrice;
else
   lowestPrice=ProgressivePrice;

if(lowestPrice>GEICOPrice)
   lowestPrice=GEICOPrice;

System.out.println("Lowest price ="+lowestPrice);
}
}

save it as car_insurance.java. Then compile it : javac car_insurance.java. Run it: java car_insurance. You will get: Lowest price =256.

Homework

Make up several grades number like 59, 75, 90. Then compare it with 60. If it is greater or equal than 60, print out "You passed". Other wise print out "You failed".

(Solution is here)

 

Try & Catch Exceptions
 
How to install JDK
Homework Solutions
 
JAVA JTable
JAVA JTree
JAVA JComboBox
JAVA JTabbedPane
Java JList
JAVA JToolTip
Javascript
WebTip
Forums
Best JAVA books
Head First JAVA, Second Editon

Effective Java Programming Language Guide

Professional Java, JDK 5 Edition

Ivor Horton's Beginning Java 2, JDK 5 Edition

 

 

 

Best books about JAVA programming from Amazon
Professional Java, JDK 5 Edition (Paperback Simply Java Programming: An Application-Driven Tutorial Approach (Paperback) Effective Java Programming Language Guide (Paperback) Head First Java, 2nd Edition (Paperback) Java : An Introduction to Problem Solving and Programming (4th Edition)

 

Printer Inkjet A Z lyricsLearn ChineseHome|PHP|Swing|HTML|JavaScript|ASP|JAVA|Forum|WebTip|Contact Us
Copyright © kidslovepc.com All rights reserved(new). Privacy|Copyright
designed by info@kidslovepc.com

Please help us cover the web site maintenance fee.
barcode scanner Thermal Printer credit card machine bar code printer