0% found this document useful (0 votes)
169 views8 pages

CSC 201-Lecture 8

This document provides programming problems and exercises related to arrays and strings, including: 1) Checking if a string or number is a palindrome. 2) Storing 10 numbers in an array and displaying them in ascending and descending order. 3) Creating a CashRegister class to calculate total price and discounts for grocery items. 4) Printing the maximum and minimum numbers in an array. 5) Replacing characters in a string with specified symbols. It also announces midterm exams for two computer science courses.

Uploaded by

pavanil
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
169 views8 pages

CSC 201-Lecture 8

This document provides programming problems and exercises related to arrays and strings, including: 1) Checking if a string or number is a palindrome. 2) Storing 10 numbers in an array and displaying them in ascending and descending order. 3) Creating a CashRegister class to calculate total price and discounts for grocery items. 4) Printing the maximum and minimum numbers in an array. 5) Replacing characters in a string with specified symbols. It also announces midterm exams for two computer science courses.

Uploaded by

pavanil
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 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

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy