CSCI 151

CSCI 151 Lab Practice

Skill set for this LAB:

Formating

Lab Practice

Problem 1

Write a program that finds the maximal and minimal values among four integeres.

Problem 2

The McDowell Restaurant chain has asked you to write a menu program for their new Fast-food service machines. Your program should print a menu like this:
McDowell.s Restaurant
Make your selection from the menu below:
1. Regular Hamburger $1.50
2. Regular Cheeseburger $1.75
3. Fish Sandwich $2.50
4. Half-pounder with cheese $2.75
5. French Fries $0.99
6. Large Soft Drink $1.25

Select 1, 2, 3, 4, 5, or 6 ----- >

Write a program that reads customer's selection and computes the price, including 7% sales tax. Note that using this menu, the customer can make just one selection. The input is one number, and the output is the price to pay or the error message "invalid choice".

Problem 3

In the Gregorian calendar a year is a leap year when the number representing it is divisible by 4, unless it is divisible by 100, unless it is divisible by 400. Thus years such as 1996, 1992, 1988 and so on are leap years because they are divisible by 4 but not by 100. For century years, the 400 rule is important. Thus, century years 1900, 1800 and 1700 while all still divisible by 4 are also exactly divisible by 100. As they are not further divisible by 400, they are not leap years. Also, you can assume that there were no leap years before 1582. Write a program that asks the user for a year and computes whether that year is a leap year. You can assume that the input is a valid positive integer less than 4000. You don.t need to check validity of the input.

Example:
Input 1980 Output Leap Year
Input 1900 Output Not a Leap Year
Input 1200 Output Not a Leap Year
Input 2000 Output Leap Year
Input 3000 Output Not a Leap Year

Problem 4

Write a program that prompts the user to enter three integer numbers. For each number, the program determine whether the input number is greater than 5, less than 5 or equals 5. The program should print an appropriate message for each case. For example, if the input is 3, the output should be: 3 is less than 5; if the input is 106, the output should be: 106 is greater than 5; and if the input is 5 , the output should be: 5 equals 5.

Problem 5

Most online shopping websites offer free shipping if you spend certain amount of money. Write a program that reads the following information: the purchase amount before tax, free shipping rule (the smallest amount of dollars consumer must spend to receive a free shipping), the tax percent(integer), and flat shipping charges. We will assume that the shipping charges are always the same and shipping charges ARE TAXABLE. The program will calculate and prints the total price of your purchase. For example: macys.com offers free shipping if you spend 99 dollars and more, so if you will spend 50 dollars, and the shipping charges are 3.99, and your state tax is 7%, the total price will be: $57.77 For example: target.com offers free shipping if you spend 50 dollars or more, so if you will spend $99.99, and the shipping charges are 5.99, and your state tax is 6%, the total will be $105.99

Problem 6

Write a program that prompts the user to enter one positive 4 digits integer. The program will do the following: if the input number is even, the program will print the digits of the number in the reverse order, and if the input number is odd, the program will calculate the sum and the product of the digits and prints the result with the appropriate message. Hint: An even number is an integer that is "evenly divisible" by 2, i.e., divisible by 2 without remainder i.e., remainder = 0