C++ loops needed in good quality

Apr 1st, 2015
Price: $85 USD

Question description

Write C++ statements for each of the following:

  1. Write the statements that allow you to input a series of numbers and print whether it is odd or even. Entering 0 causes the program to quit.
  2. Write the statements to input numeric exam scores from a file and output the appropriate letter grade.
  3. Write a loop that will continuously input and print the names of contest participants, until QUIT is entered in place of the name.

Implement (4-8) using a while loop and a for loop:

  1. Write code to print Towson University 10 times.
  2. Write code to print the numbers from 1 to 10.
  3. Write code to print the numbers from 10 to 1.
  4. Write code to print the following numbers:

2 4 6 8 10 12

  1. Write code that prints your name 5 times.
  1. Write code that will input a number and print the number, the square of the number, and the cube of the number. Continue the operation until 999 is entered.
  2. Write code that will request the length and width of a rectangle until 0 is entered for either the length or the width. Print the area and perimeter for each set of inputs.
  3. Write code that reads in integers and then counts and prints out the number of positive integers and negative integers. If a value is zero, it should not be counted. The process should continue until end-of-file occurs.

12.  What is the output for the following loop?

int number;

number = 1;

while (number < 11) {

  number = number + 1;

  cout << number << endl;



13.  What is the output for the following loop?

int number;

bool done;

number = 2;

done = FALSE;

while (!done) {

  number = number * 2

  if (number > 12)

  done = TRUE;

  cout << number << endl;



14.  What is the output of the following if the file contains: 2 3 4 5 6 7

int sum, num;

sum = 0;

infile >> num;

while (infile) {

 if (num % 2 == 0)

  sum = sum + num;

  infile >> num;


cout <<  sum << endl;


15.  Write a program that prints out the sequence of all the hour and minute combinations in a day, starting with 1:00 and ending at 11:59.

Write the complete code and perform 3 traces.  Pick good test data.

16 Design an algorithm that will prompt for, receive, and total a collection of payroll amounts entered at the terminal until a sentinel amount of 999 is entered. After the sentinel has been entered, display the total payroll amount to the screen.

17. Design an algorithm that will read a series of integers from the screen. The first integer is special, as it indicates how many integers will follow. Your algorithm is to calculate and print the sum and average of the integers, excluding the first integer and display these values to the screen.

18. Design an algorithm that will prompt for and receive the measurement for the diameter of a circle and calculate and display the area and circumference of the circle. Your program is to continue processing until the sentinel of 9999 is entered.

19. A file of student records contains name, gender (M or F), age, in years, and marital status (single or married) for each student. Design an algorithm that will read through the file and calculate the numbers of married men, single men, married women and single women, For all single men under 30, display "Bachelor".

The input statement looks like:  infile >> name >> gender >> age >> maritalStatus;

Tutor Answer

(Top Tutor) aazam
School: Rice University

Studypool has helped 1,244,100 students

Review from student
" Wow this is really good.... didn't expect it. Sweet!!!! "
Ask your homework questions. Receive quality answers!

Type your question here (or upload an image)

1825 tutors are online

Brown University

1271 Tutors

California Institute of Technology

2131 Tutors

Carnegie Mellon University

982 Tutors

Columbia University

1256 Tutors

Dartmouth University

2113 Tutors

Emory University

2279 Tutors

Harvard University

599 Tutors

Massachusetts Institute of Technology

2319 Tutors

New York University

1645 Tutors

Notre Dam University

1911 Tutors

Oklahoma University

2122 Tutors

Pennsylvania State University

932 Tutors

Princeton University

1211 Tutors

Stanford University

983 Tutors

University of California

1282 Tutors

Oxford University

123 Tutors

Yale University

2325 Tutors