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

OK. You have learned a lot in previous lessons. By using what you learned so far, you could ask me to do a lot of things

Let us play a little bit. Let us pretend that you are a doctor. Your dog catch a cold. He got fever, red eye, running nose and sneezing a lot! You gave a prescription and ask me to calculate how much money the medcines will cost.

The prescription is:

5 yellow pills for fever

4 blue pills for allergy symptoms (sneezing, running nose)

I called pharmacy and find out that yellow pill cost 0.83 per pill and blue pill is 1.95 per pill. So I type the following code to calculate the cost:
class medicine
{
public static void main(String[] args)
{
int NoOfYellowPills=5;
int NoOfBluePills=4;
double priceOfYellowPill=0.83;
double priceOfBluePill=1.95;
double totalCost=NoOfYellowPills*priceOfYellowPill
+NoOfBluePills*priceOfBluePill;

System.out.println("Total medicine cost="+totalCost);
}
}

Save it as medicine.java. Then I compile the code: javac medicine.java.

Then I run the code: java medicine

Now i get the result: Total medicine cost=11.95

In the above code, you may see that a statement may write into serveral lines(highlighted in red).

OK, doctor, I finish my job.

Homework

Suppose you will have a birthday party next Saturday. You got $234 dollars from your grandparentsa. You plan to invite friends to see "Star War (3)".. Every one needs a ticket ($5), a drink ($1.1) and popcorn($2.3). How many friends you could invite at most (Don't forget yourself)?
Please print out something like "Maximum number of friends="...

(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