You are on page 1of 8

CSC 201

Lecture - 8
Team work Session - 2
Arrays and Strings-Problems
1) Write a program to check if a user entered
string or number is a Palindrome or not. (Ex:
The string ‘dad’ is a palindrome! The number
‘121’ is a palindrome! What about the string
‘MADAM’?)
2) Create an array of program size 10 and store
10 numbers. Write a program to display the
numbers of the array in both ascending and
descending order.
3) Create a class named 'CashRegisterDemo' for
a grocery store.
This will calculate the total price of item bought
by a customer and print out the number of
items and total price as a receipt for the
customer. If the customer bought grocery
above $100 then he/she gets a 5% discount
from the total price.
Example output: The customer who bought
120$ worth of items will pay 120 * 0.05 = 114$
(Subtract 6$ from 120).
Conditions:
a) Your program should keep asking a
customer to enter a price (of type double)
of the items he/she bought.
b) When customer enters 0 as item price,
then the program should stop asking for
user input.
Your output should be similar to this.

Date: 01/09/2009
Welcome to ABC supermarket.
Please enter name: Pavani
Please enter the price of 1st item: 20.0
Please enter the price of 2nd item: 60.0
Please enter the price of 3rd item: 70.0
Please enter the price of 4th item: 0

You bought 3 items and the price is $150


Discount applied: 5%
Total price: $142.50.
Thank you for shopping!

Do you need arrays here?


4)Take an array of size 10, print the
maximum and minimum number as your
output.
5)Input a string to your program, Ex: “Hello
CSC 201,How are you?” and your output
should be “Hello*CSC*@)!,How*are*you?”
Programming Assignment - 2
• Car Rental System (Simple reservation
Java program).
Announcement
• Midterm Examination for CSC 201 to be
scheduled on 10/20/09 – Tuesday
Timings: 11:00am – 12:50pm

• In-class quiz for CSC 185 to be conducted


on 10/13/2009 - Tuesday

You might also like