------------------------------------------
#include
#include
using namespace std;
int main()
{
//Part(a)----Square
cout<
*********
* *
* *
* *
* *
* *
* *
* *
*********
The oval is printed as:
***
* *
* *
* *
* *
* *
* *
* *
***
The arrow os printted as:
*
***
*****
*
*
*
*
*
*
The diamond is printted as:
*
* *
* *
* *
* *
* *
* *
* *
*
#include
#include
using namespace std;
int main()
{
//Digits of a number
int num1=0;
int rem1=0;/*All values are initialize to zero to overwrite the garbage value*/
int rem2=0;
int rem3=0;
int rem4=0;
int rem5=0;
cout<<"Enter the five-digit number:"<>num1;
cout<<"The given number is separated as:"<
#include
using namespace std;
int main()
{
float total_miles=0.0;
float cost_per_gallon=0.0;
float average_miles_per_gallon=0.0;
int parking_fees=0;
int tolls_per_day=0;
double cost_per_day_of_driving=0.0;
cout<<"-----------------------------------------------------------------"<>total_miles;
cout<<"Enter Cost per gallon of gasoline:"<>cost_per_gallon;
cout<<"Enter Average miles per gallon:"<>average_miles_per_gallon;
cout<<"Enter Parking fees per day:"<>parking_fees;
cout<<"Enter Tolls per day:"<>tolls_per_day;
cout<
Task 4. Male and Female Percentages) Write a program that asks the user for the number of males and
the number of females registered in a class.
The program should display the percentage of males and females in the class.
#include
using namespace std;
int main()
{
int male=0;
int female=0;
int total=0;
float male_per=0.0;
float female_per=0.0;
cout<<"Class male and female percentage:"<>male;
cout<<"Enter the number of females in your class:"<>female;
//Percentage Calculation
total=male+female;
male_per=((float)male/total)*100;
female_per=((float)female/total)*100;
cout<<"The total number of students in your classroom = "<
Task 5. Ingredient Adjuster) A cookie recipe calls for the following ingredients:
• l.5 cups of sugar
• 1 cup of butter
• 2. 75 cups of flour
The recipe produces 48 cookies with this amount of the ingredients.
Write a program that asks the user how many cookies he or she wants to make, then displays the
number of cups of each ingredient needed for the specified number of cookies.
#include
#include
using namespace std;
int main()
{
float cups_of_sugar=1.5;
int cups_of_butter=1;
float cups_of_flour=2.75;
int total_cookies=48;
int cookies=0;
cout<<"Ingrediant_Calculator:"<>cookies;
//Ingrediants_Calculation
cups_of_sugar=(cups_of_sugar*cookies)/total_cookies;
cups_of_butter=((float)cups_of_butter*cookies)/total_cookies;
cups_of_flour=(cups_of_flour*cookies)/total_cookies;
cout<<"The ingrediants you need to make the "<
Task 6.(Box Office) A movie cheater only keeps a percentage of the revenue earned from ticket sales.
The remainder goes to the movie distributor.
Write a program that calculates a theater's gross and net box office profit for a night.
The program should ask for the name of the movie, and how many adult and child tickets were
sold.
(The price of an adult ticket is $10.00 and a child's ticket is $6.00.)
It should display a report similar to:
Assume the theater keeps 20 percent of the gross box office profit
.
The output is as follows:
Ingrediant_Calculator:
______________________
Enter the number of cookies that you want to make:
700
The ingrediants you need to make the 700 number of cookies :
You need 21.9 cups_of_sugar
You need 14 cups_of_butter
You need 40.1 cups_of_flour
#include
#include
using namespace std;
int main()
{
float cups_of_sugar=1.5;
int cups_of_butter=1;
float cups_of_flour=2.75;
int total_cookies=48;
int cookies=0;
cout<<"Ingrediant_Calculator:"<>cookies;
//Ingrediants_Calculation
cups_of_sugar=(cups_of_sugar*cookies)/total_cookies;
cups_of_butter=((float)cups_of_butter*cookies)/total_cookies;
cups_of_flour=(cups_of_flour*cookies)/total_cookies;
cout<<"The ingrediants you need to make the "<
Task 7.If you have two fractions, a/b and c/d, their sum can be obtained from the formula
Thier output as:
-----------Fraction_Sum-----------
___________________________________
Enter the fraction 1:
1/2
Enter the fraction 2:
2/5
The sum of these two fractions = 9/10
Write a program that encourages the user to enter two fractions, and then displays their sum in
fractional form.
(You don’t need to reduce it to lowest terms.) The interaction with the user might
look like this:
Enter first fraction: 1/2
Enter second fraction: 2/5
Sum = 9/10
You can take advantage of the fact that the extraction operator (>>) can be chained to read in
more than one quantity at once:
cin >> a >> dummychar >> b;
#include
using namespace std;
int main()
{
char dummy_char;
int num1_N=0;
int num1_D=0;
int num2_N=0;
int num2_D=0;
int num1_to=0;
int num2_to=0;
int denominator=0;
int numinator=0;
cout<<"-----------Fraction_Sum-----------"<>num1_N>>dummy_char>>num1_D;
cout<<"Enter the fraction 2:"<>num2_N>>dummy_char>>num2_D;
//calculations
num1_to=num1_N*num2_D;
num2_to=num2_N*num1_D;
numinator=num1_to+num2_to;
denominator=num1_D*num2_D;
//Display
cout<<"The sum of these two fractions = "<
Task 8. You can convert temperature from degrees Celsius to degrees Fahrenheit by multiplying by 9/5
and adding 32. Write a program that allows the user to enter a floating-point number
representing degrees Celsius, and then displays the corresponding degrees Fahrenheit.
#include
using namespace std;
int main()
{
const float constant=1.8;
float celsius=0.0;
float farhnheit=0.0;
cout<<"-------------Celsius to farhenheit--------"<>celsius;
farhnheit=(celsius*constant)+32;
cout<<"The temperature in the farhenheit = "<
Task 9. By default, output is right-justified in its field. You can left-justify text output using the
manipulator setiosflags(ios::left). (For now, don’t worry about what this new notation means.)
Use this manipulator, along with setw(), to help generate the following output:
last Name First Name Street_Address Town State
-------------------------------------------------------------
Jones Bernard 109 Pine Lance Littletown MI
O'Brian Coleen 42 E. 99th Ave. Bigcity NY
Wong Harry 121-A Alabama St.Lakeville IL
#include
#include
using namespace std;
int main()
{
cout<
Task 10.A serial transmission line can transmit 960 characters a second. Write a program that will
calculate how long it will take to send a file, given the file's size. Try it on a 400MB (419,430,400
byte) file. Use appropriate units. (A 400MB file takes days.)
#include
#include
using namespace std;
iint main()
{
const int characters_per_second=960;
const int sizeOfCharacter_per_byte=1;
long long int file_bytes=419430400;
long double days=0.0;
cout<<"------------File Sendig Time/400MB--------"<