CSC 201-Lecture 8
CSC 201-Lecture 8
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