Q1a) Instructions Consider the following program segment: //inc

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Q1a)

Instructions

Consider the following program segment:

//include statement(s)
//using namespace statement
 
int main()
{
//variable declaration
 
//executable statements
 
//return statement
}

Write a C++ statement that includes the header file iostream.

Proceed through all the steps in this activity by clicking the navigation arrows at the bottom of this pane after completing each step.

Write a C++ statement that allows you to use cin, cout, and endl without the prefix std::.

Write C++ statement(s) that declare the following variables: num1, num2,num3, and average of type int.

Write C++ statements that store 125 into num1, 28 into num2, and –25 into num3.

Write a C++ statement that stores the average of num1, num2, and num3 into average.

Final Step:

Write C++ statement(s) that output the values of num1, num2, num3, and average.

Then compile and run your program by clicking the blue run button on the right side of the screen.

 

Q1b)

Write a program to implement and test the algorithm that you designed for Exercise 15 of Chapter 1. The instructions to Exercise 15 have been posted below for your convenience:

Exercise 15

Given the radius, in inches, and price of a pizza, design an algorithm to find the price of the pizza per square inch.

You may assume that the value of π = 3.141593.

In your program, declare a named constant PI to store this value.

Below is an example of how the completed program should work:

Enter the radius of the pizza: 20 Enter the price of the pizza: 22 The price per square inch is: 0.017507

Since your program handles currency, make sure to use a data type that can store decimals.

 

Q1c)

A milk carton can hold 3.78 liters of milk. Each morning, a dairy farm ships cartons of milk to a local grocery store. The cost of producing one liter of milk is $0.38, and the profit of each carton of milk is $0.27.

Write a program that prompts the user to enter:

  1. The total amount of milk produced in the morning.

The program then outputs:

  1. The number of milk cartons needed to hold milk.

    • Round your answer to the nearest integer.
  2. The cost of producing milk.

  3. The profit for producing milk.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
C-string
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education