You are on page 1of 2

^ K K W  ^   

  

Instructions:

Answer all questions. The due date is 17th January 2011. Use the following comments in
every Java codes that you submitted:

/*-----------------------------------------------------
* CSC1103 Assigment No: #
* Author: 1) Your name & Matric No.
* 2) Your partner name & Matric No.
* Section:
* Date:
*-------------------------------------------------------*/

1. Write a program that determines number of vowel (a, e, i, o, u) exist in any string
given by the user. For example a string “Assalamualaikum” will result of a = 5,
e = 0, i = 1, o = 0 and u = 2. Name your program as “Vowel.java”

2. Write an application using if statement that prints out a message based on the
following rules:

If Total Points Are Message to Print


>= 100 You won a free cup of pepsi.
>= 200 You won a free cup of pepsi with 2
pieces of chicken wings.
>= 300 You won a free cup of pepsi with 2
pieces of chicken wings and
coleslaw.
>= 400 You won a free cup of pepsi with 2
pieces of chicken wings, coleslaw
and french fries.
>=500 You won a free cup of pepsi with 2
pieces of chicken wings, coleslaw
and french fries for a week.
0 - 100 Please try again.

Your program should allow the user to key in the total points as integer value.
Name your program as “WinPepsi.java”

3. Develop a Java application that will determine the commission for salespeople
working in the XYZ Company. The salespeople receive RM200 per week plus
9% of their gross sales for that week. For example, a salesperson who sells
RM5000 worth of items in a week receives RM200 plus 9% of RM5000, or a total
of RM650. Below is the price of each item:
Item Price (RM)
1 239.99
2 129.75
3 99.95
4 350.89

Read an input file (saved as items.txt) that contains a list of item and the number
of quantity sold by a salesperson, separated by a new line. Your “items.txt” may
looks like this:

1 7
2 15
3 25
4 10
Note that the first column represents the product or item; the second column
represents the number of quantity sold by the salesperson (columns are separated
by a whitespace).

The program should calculate the gross sales (i.e. quantity sold * price) and
displays that salesperson’s earning. Display the results using only two decimal
places. Name your program as Sales.java. For the above sample of quantity sold,
the output should be like this:

Total Gross Sales: RM9633.83


Earning this week: RM1067.04

You might also like