CHAPTER 3 REVIEW EXERCISES Code statements: For the following otherwise specifie
ID: 3746431 • Letter: C
Question
CHAPTER 3 REVIEW EXERCISES Code statements: For the following otherwise specified. exercises, presume that the relevant variables have already been declared, unless integer variable Write a statement that reads an integer value from standard input into the number. Write a statement that reads a floating point (real) value from standard input into the double variable temperature .Assume that we have a string type variable called name and short type variable called age. Write code that asks the user and accepts the user entered values into the variables name and age. Then print the message "The age of cnames is cage>.- For example, if your code read in "Sara" and 17, then your code would print out "The age of Sara is 17- Write code that would reads a number from the keyboard into the integer variable number.Then print out the variable 's value, thrice the value, and the cube of the value, separated by spaces. For example if I enter 2, the code should display 268 Assume the dimensions (width and length) of one room have been read into two float variables (width1 and length1), and the dimensions of a second room have been read into two other variables(width2 and length2). Write a single expression that will calculate the total area of the two rooms and store it in a variable named totalArea. * .Assume that price is an integer variable that contains the price (in US currency) in cents of an item, Write a statement that prints the value of price in the form "X dollars and Y cents" So, if the value of price was 4321, your code would print "43 dollars and 21 cents .Assume that brushCount is an integer variable containing the number of paint brushes in a box and that boxCount is an integer variable containing the number of boxes in a store. Write an expression that calculates the average number of brushes per box. Write a statement using a compound assignment operator to calculate half price of a given ticket price stored in the variable. . .Write a statement using the increment operator to increase the value of the integer variable num_steps by 10. statement that prints it out in a print field of 10 positions string variable prefix Assume that classCount is an int variable that has been given a value.Write a Write an expression that concatenates the string variable suffix onto the end of the Program Joe's Pizza Palace needs a program to calculate the number of slices a pizza of any size can be divided into. Write a complete program that will perform the following steps: Ask the user for the diameter of the pizza in inches. Calculate the number of slices that may be taken from a pizza of that size. .Display a message telling the number of slices. To calculate the number of slices that may be taken from the pizza, you must know the following facts: .Each slice should have an area of 14.125 inches. To calculate the number of slices, simply divide the area of the pizza by 14.125 The area of the pizza is calculated with this formula: Area - "pir squared" where pi is approximately 3.14159 and r is the radius (half the diameter).Explanation / Answer
1 Solution :
#include <iostream>
#include <string.h>
using namespace std;
int main()
{
int x;
//Solution for point 1
cout<<"Enter the Value:"<<endl;
cin>>x;
cout<<"The Value Stored as Integer is: "<<x<<endl;
//Solution for point 2
double temperature;
cout<<"Enter the Temperature in float: "<<endl;
cin>>temperature;
cout<<"The Value Stored is: "<<temperature<<endl;
//Solution for point 3
string name;
int age;
cout<<"Enter Name and age: "<<endl;
cin>>name>>age;
cout<<"The age of "<<name<<" is "<<age<<endl;
//Solution for point 4
int value;
cout<<"Enter the value whose trice and cube is to be calculated: "<<endl;
cin>>value;
cout<<value<<" "<<value*3<<" "<<value*value*value<<endl;
//Solution for point 5
int length[2], width[2];
cout<<"Enter length and width of Room1: "<<endl;
cin>>length[0]>>width[0];
cout<<"Enter length and width of Room2: "<<endl;
cin>>length[1]>>width[1];
int total = length[0]*width[0] + length[1]*width[1];
cout<<"The total area of the room is "<<total<<endl;
//Solution for point 6
int usPrice, dollars,cents;
cout<<"Enter price in US: "<<endl;
cin>>usPrice;
dollars = usPrice/100;
cents= usPrice-(dollars*100);
cout<<"Dollars: "<<dollars<<" Cents: "<<cents<<endl;
//Solution for point 7
int brushCount, boxCount;
cout<<"Enter the total number of Brush: "<<endl;
cin>>brushCount;
cout<<"Enter number of Boxes: "<<endl;
cin>>boxCount;
cout<<"Average number of brush present in boxes: "<<brushCount/boxCount<<endl;
//Solution for point 8
int ticketPrice;
cout<<"Enter the Ticket Price: "<<endl;
cin>>ticketPrice;
ticketPrice /=2;
cout<<"The New Price is: "<<ticketPrice<<endl;
//Solution for point 9
int val;
cout<<"Enter the Value to increnebt by 10: "<<endl;
cin>>val;
val +=10;
cout<<"The Value is :"<<val<<endl;
//Solution for point 10
int classCount[20] ={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20};
cout<<"Value of 10th position is: "<<classCount[10]<<endl;
//Solution for point 11
string pre, suf, result;
pre = "prestring";
suf = "suffix";
cout<<"Prefix is: "<<pre<<endl;
cout<<"Suffix is: "<<suf<<endl;
result = pre + suf;
cout<<"The New String is: "<<result<<endl;
return 0;
}
==============================================
Solution 2:
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
int pizzaDaimeter;
cout<<"Enter the Pizza size in inches: "<<endl;
cin>>pizzaDaimeter;
int radius = pizzaDaimeter/2;
int area = 3.14159 * radius* radius;
int slices = ceil(area/14.125);
cout<<"Number of Slices will be: "<<slices;
return 0;
}