Question

In: Computer Science

1. Write a program that read a sequence of positive integer inputs and print the sum...

1. Write a program that read a sequence of positive integer inputs and print the sum and average of the inputs. Assume that the user always enters a positive number (integer) as an input value or an empty space as a sentinel value. Please use the below to test your code [45 points]:

Enter an int value or empty string to end: 98

Enter an int value or empty string to end: 78

Enter an int value or empty string to end: 77

Enter an int value or empty string to end: 1

Enter an int value or empty string to end: 10

Enter an int value or empty string to end:

Sum: 264 Average: 52.8

2. Write a program that read a sequence of positive integers and print the number of odd inputs entered by the user. The sentinel value is an empty string. Use the following test case [48 points]:

Enter integer or empty string to end: 3

Enter integer or empty string to end: 2

Enter integer or empty string to end: 10

Enter integer or empty string to end: 5

Enter integer or empty string to end: 6

Enter integer or empty string to end: 7

Enter integer or empty string to end:

number of odd integers entered: 3

3.Write a program that read a sequence of positive integers and print the average value of all the odd integers entered by the user (hint: you need to compute the sum of all the odd integers first to calculate the average). Use the following test case [7 points]:

Enter an int value or empty string to end: 10

Enter an int value or empty string to end: 20

Enter an int value or empty string to end: 5

Enter an int value or empty string to end: 10

Enter an int value or empty string to end: 15

Enter an int value or empty string to end:

average : 10.0

use python code for all questions

Solutions

Expert Solution


Related Solutions

Using Python. Write a program that reads a sequence (unknown number of inputs) of integer inputs...
Using Python. Write a program that reads a sequence (unknown number of inputs) of integer inputs and prints the number of even and odd inputs in the sequence. please explain. Thanks
Write a program to read in a collection of integer values, and find and print the...
Write a program to read in a collection of integer values, and find and print the index of the first occurrence and last occurence of the number 12. The program should print an index value of 0 if the number 12 is not found. The index is the sequence number of the data item 12. For example if the eighth data item is the only 12, then the index value 8 should be printed for the first and last occurrence....
C program, please Write a program that reads a sequence of 10 integer inputs and prints...
C program, please Write a program that reads a sequence of 10 integer inputs and prints the smallest and largest of the inputs and the number of even and odd inputs. for a beginner please, you could use a while loop,if-else,
A. Write a program 1. Prompt the user to enter a positive integer n and read...
A. Write a program 1. Prompt the user to enter a positive integer n and read in the input. 2. Print out n of Z shape of size n X n side by side which made up of *. B. Write a C++ program that 1. Prompt user to enter an odd integer and read in the value to n. 2. Terminate the program if n is not odd. 3. Print out a cross shape of size n X n...
Write a c++ program of the Fibonacci Sequence. Have the user enter a positive integer n...
Write a c++ program of the Fibonacci Sequence. Have the user enter a positive integer n and compute the nth Fibonacci number. The program should end when the user enters a number less than or equal to zero
In C Write a program to read a one-dimensional array, print sum of all elements using...
In C Write a program to read a one-dimensional array, print sum of all elements using Dynamic Memory Allocation.
Envision an algorithm that when given any positive integer n, it will print out the sum...
Envision an algorithm that when given any positive integer n, it will print out the sum of the squares from 1 to n. E.g. given 4 the algorithm would print 30 (because 1 + 4 + 9 + 16 = 30) You can use multiplication denoted as * in your solution and you do not have to define it (e.g. 2*2=4) Write pseudocode for this algorithm using iteration (looping). Create a flow chart Implement solution from flowchart in Python at...
Write a MIPS assembly program to repeatedly read two non-negative integers and print the integer product...
Write a MIPS assembly program to repeatedly read two non-negative integers and print the integer product and quotient without using the multiplication and division instructions. Each input number will be entered on a separate line. Your program will terminate when two zeroes are entered by the user. If only the second number in a pair is zero, then a divide-by-zero error message should be printed for the division operation. Use comments generously in your program. Test your program with the...
Write a MIPS assembly program to repeatedly read two non-negative integers and print the integer product...
Write a MIPS assembly program to repeatedly read two non-negative integers and print the integer product and quotient without using the multiplication and division instructions. Each input number will be entered on a separate line. Your program will terminate when two zeroes are entered by the user. If only the second number in a pair is zero, then a divide-by-zero error message should be printed for the division operation. Use comments generously in your program. Test your program with the...
Write a MIPS assembly program to repeatedly read two non-negative integers and print the integer product...
Write a MIPS assembly program to repeatedly read two non-negative integers and print the integer product and quotient without using the multiplication and division instructions. Each input number will be entered on a separate line. Your program will terminate when two zeroes are entered by the user. If only the second number in a pair is zero, then a divide-by-zero error message should be printed for the division operation. Use comments generously in your program. Test your program with the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT