Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

COSC-1436, Lab Assignment 2 Answer the following questions using your own words. Compose complete sentences and add them to a word processing document that is

COSC-1436, Lab Assignment 2

Answer the following questions using your own words. Compose complete sentences and add them to a word processing document that is compatible with Microsoft Word. Include your full name and the name of the assignment at the top of the document. Name the file XYLab1, where X and Y are your first and last initials.

Questions (50 points):

1. Compose a single C++ programming statement that will declare the variables named hours, minutes, and seconds to be integer (int) data type with hours initialized to 8, minutes initialized to 20, and seconds initialized to 0.

2. Assume that an integer variable named seats has the value 16. Compose a C++ programming statement that will display the value of the variable named seats so that it will occupy 5 positions on the screen when the statement is executed.

3. Assume that a double variable named voltage has the value 110.251. Compose a C++ programming statement that will display the value of the variable named voltage in such a way that it occupies 10 positions on the screen and displays 2 digits after the decimal point. (Do not display using scientific notation.)

4. Assume that a double variable named alpha contains the value of an angle in radians. Compose a C++ statement that will display the sine of that angle so that it occupies 12 positions on the screen and displays 3 digits after the decimal point.

5. Assume that when prompted for their name, your user enters their full name (first and last names separated by a space). Compose the C++ programming statements that will:

  • declare a variable named customer to have a string data type.
  • prompt the user for their full name.
  • read the users entry and store it in the variable named customer.

Programming Exercise (50 points):

A bag of cookies holds 40 cookies. The calorie information on the bag claims that there are 10 servings in the bag and that a single serving equals 300 calories. Design and write a C++ program that prompts your user for the number of cookies that he or she actually ate from one of these bags and then displays the number of calories they consumed.

We want you to learn how to write programs that are robust and potentially reusable.

Use variables to represent the given information, such as the number of cookies in a bag and the number of calories in a serving. Compose statements using the given variables to calculate the number of calories in each cookie. The use of magic is not permitted in computer programming. You, as the programmer must compose steps that store given information in variables and then use these variables to determine values such as the number of calories in each cookie.

Package your solution to this Programming Exercise in a compressed file and submit the compressed file along with the word processing file that contains your answers to the Questions above.

NOTE: Remember to submit both files; the word processing file that contains your answers to the questions above and the compressed file that contains your solution to the cookie-based programming exercise.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Database 11g SQL

Authors: Jason Price

1st Edition

0071498508, 978-0071498500

More Books

Students also viewed these Databases questions

Question

3. Evaluate a Web-based training site.

Answered: 1 week ago