Programming Exercises
Essay by jimmmer • April 3, 2019 • Essay • 430 Words (2 Pages) • 676 Views
Programming Exercises 3
Due: February 13th, 2019
You will be marked on:
- Clarity of code
- Variables are named appropriately
- Code contains AT LEAST 2 comments
- Formatting is consistent
- Output is clear and well organized (Spacing, capitals, colons, descriptions etc.)
- Correctness of Code
- Code compiles
- Code produces expected output
- Modify your Guessing game program (done in class) to include a message if the users guess is too high or too low.
2. Write a program that asks the user for a positive non-zero integer value. The program should then use a loop to get the sum of all the integers from 1 to the number entered. For example, if the user enters 5 the output should be 15 (5+4+3+2+1).
3. Write a program that calculates the amount a person would earn over a period of time if his or her salary is one penny the first day and doubles each day. The program should display a table showing the salary for each day and the total earned at the end of the period. The output should be displayed in dollars. DO NOT accept an input less than 1 for the days worked.
4. Write a program that asks the user to enter a string, then asks the user to enter a character. The program should count and display the number of times that the specified character appears in the string.
5. Write a program that uses nested loops to collect data and calculate the average rainfall over a period of years. First the program should ask for the number of years. The outer loop will iterate once for each year. The inner loop will iterate 12 times, once for each month. Each iteration of the inner loop will ask the user for the inches of rainfall for that month. After all iterations, the program should display the number of months, the total inches of rainfall, and the average rainfall per month for the entire period. DO NOT accept a number less than 1 for the number of years and DO NOT accept negative numbers for the monthly rainfall.
...
...