CSC 243 Lab 2, Fall 2012
Lebanese American University · Introduction to Object Oriented Programming · 2 pages · Dr. Azzam Mourad
More CSC 243 files
Show the text of this lab
Problem1:
Assume you own a grocery shop where clients always buy 3 items (all prices are in
dollars). To facilitate the billing process you write a program that reads the item
names and prices and generates an invoice. For example, if a client buys Chocolate
(at $0.5), Gum (at $1), Water (at $0.5), the program output should look as follow:
Please enter the first item name:
Chocolate
Please enter the first item price:
1.5
Please enter the second item name:
Gum
Please enter the second item price:
1.5
Please enter the third item name:
Water
Please enter the third item price:
1.5
Invoice is:
Chocolate $1.5
Gum $1.5
Water $1.5
Total $4.5
Note that all prices are in dollars and you should use number formats to generate the invoice (do not use
string concatenation to add the dollar sign).
Solution: http://www.javaproblems.com/2013/12/creating-invoice-of-shop-
in-java.html
Problem 2: (30 points)
Write a program that would read the class grades from the user(5 grades). Then the code will display the
maximum grade, minimum grade, and average of the. Then compute the average letter grade using the
conditional statement(if else) and print the class average.
Please enter the grades:
85
98
72
64
53
Then, your program should print:
Maximum: 98
Minimum: 53
Average: 74.4
The Class Average is: C+
Solution: http://www.javaproblems.com/2013/12/calculating-minimum-
maximum-and-average.html
Problem 3:
Write a program that takes the name and the age of the user. The program should check the age of the
user and then prints out if the person can get his driver license or not.
If the age is under 18 then you should print “ ……. Too young to get his/her driving license”
If the age is greater than or equal to 18 then the program should print “……. can have his/her Driving
License”.
The program should look as follows:
Enter Name:
Talal
Enter Age:
16
Talal is too young to get his driving License
Solution: http://www.javaproblems.com/2013/12/legal-age-calculator-in-
java.html