# 2 program design

1. Maggie is planning for a trip for her and her friends. The group decided to purchase snacks together and split the cost. There are10peoplein total.
The snacksare:
1. Energy bars-\$3.99/box,
2. Candy bars-\$2.39 /box,
3. Chips -\$4.79/bag,
4. Pretzels-\$2.99/bag,
5. Popcorns-\$3.50 /bag
6. Energy drinks-\$4.99/half dozen
Write a program to calculate the cost per person. The program allows the user to select an item, input the number of items, and calculate the cost per person.
An example input/output: Please select from the list:
1. Energy bars -\$3.99 /box,
2. Candy bars -\$2.39 /box,
3. Chips -\$4.79 /bag,
4. Pretzels -\$2.99/bag,
5. Popcorns -\$3.50 /bag
6. Energy drinks -\$4.99/half dozen
enter selection: 1
Enter number of boxes: 3
Enter selection: 3
Enter number of bags: 2
Enter selection: 7
Invalid selection, select from 1 to 6, enter 0 to stop selection
Enter selection: 6
Enter number of drinks as multiples of six (6, 12, 18…): 24
Enter selection: 5
Enter number of bags: 1
Enter selection: 0
Cost per person(\$): 4.50
2)If the user selects a number out of the range (1 through 6), display a message and allows the user to select again. When user enters 0, the program should exit from the loop for selection.
3)Use a switch statement to compute the amount due according to the selection(s).
4)Format the output to two decimal digits.

Program 2. In this program, we define a word to be valid if all characters of the word are alphabetic letters and one of following conditions holds:
1. All letters are capitals, like “UCLA”,
2. All letters are not capitals, like “program”. Write a program that prompts the user to enter a word. The program determines if the input is a valid word or invalid.
2)The user input ends with the user pressing the enter key (a new line character).
3)Use getchar() to read in the input. Character handling functions are allowed.
Example 1:
Input: “fall”
Output: valid
Example 2:
Input: “8littlepigs”
Output: Invalid
Example 3:
Input: “CpE”
Output: Invalid
Example 4:
Input: “CSE2021”
Output: Invalid
Example 5:
Input: “CSE”
Output: Valid