0% found this document useful (0 votes)
33 views

Assignment 2

The document contains code snippets and questions from an assignment on programming fundamentals. It includes multiple C++ programs that calculate things like miles driven based on tank capacity and miles per gallon, total price after markup and taxes, hard drive size in gigabytes, number of milk cartons needed, and more. The programs request user input, perform calculations, and output results.

Uploaded by

Zeeshan Farooq
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views

Assignment 2

The document contains code snippets and questions from an assignment on programming fundamentals. It includes multiple C++ programs that calculate things like miles driven based on tank capacity and miles per gallon, total price after markup and taxes, hard drive size in gigabytes, number of milk cartons needed, and more. The programs request user input, perform calculations, and output results.

Uploaded by

Zeeshan Farooq
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Assignment#2

IPROGRAMMING FUNDAMENTAL

SUBMITTED BY: ZEESHAN FAROOQ

ROLL N0: 20011598-026


COURSE CODE: SE-101
SUBMITTED TO: MS.UZMA
SUBMITTION DATE: JANUARY 23,2022
SECTION: BS-SOFTWARE ENGINEERING (III-A)
Q#2.11

#include <iostream>

using namespace std;

int main()
{
int milesPerGallon, tankCapacity;

cout << "Please enter the capacity of the tank: ";


cin >> tankCapacity;

cout << "Please enter the miles per gallons: ";


cin >> milesPerGallon;

cout << "This mean that you can drive " << tankCapacity * milesPerGallon << "
miles on a full tank." << endl;

return 0;
}
Q#2.13

#include <iostream>

using namespace std;

int main()
{
double originalPrice, salesTaxRate, totalPrice, markupPercentage, salesTaxPrice,
markupPrice;

cout << "Please enter the original price: $";


cin >> originalPrice;

cout << "Please enter the mark-up percentage: ";


cin >> markupPercentage;

cout << "Please enter the sales tax percentage: ";


cin >> salesTaxRate;

markupPrice = originalPrice * (markupPercentage / 100);


salesTaxPrice = originalPrice * (salesTaxRate / 100);
totalPrice = originalPrice + salesTaxPrice + markupPrice;

cout << "Original Price: $" << originalPrice << endl;


cout << "Sales Tax: $" << salesTaxPrice << endl;
cout << "Mark-Up: $" << markupPrice << endl;
cout << "Total Price: $" << totalPrice << endl;
return 0;
}
Q#2.14
#include <iostream>

using namespace std;

int main()
{
double hddSpecifiedSize, hddRealSize;

cout << "Please enter the size of the HDD: ";


cin >> hddSpecifiedSize;

hddSpecifiedSize = hddSpecifiedSize * 1000 * 1000; //Give the size in bytes


hddRealSize = hddSpecifiedSize / 1024 / 1024; //Recompile to GB

cout << "Hard Drive is actually: " << hddRealSize << "GB" << endl;
return 0;
}
Q#2.16

#include <iostream>
using namespace std;

int main(int argc, char** argv)


{
double
milkproduced,cartonsrequired,cartonsize,productioncost,cartonprofit;
cartonsize=3.78;
productioncost=0.38;
cartonprofit=0.27;
cout<<"how much milk did you produce:";
cin>>milkproduced;
cartonsrequired=milkproduced/cartonsize;
cout<<"that is going to required: "<<cartonsrequired<<"cartons"<<endl;
cout<<"total cost to produce: "<<cartonsrequired*productioncost<<endl;
cout<<"total profit :"<<cartonsrequired*cartonprofit<<endl;
return 0;
}
Q#2.18

#include <iostream>
using namespace std;

int main(int argc, char** argv)


{
double payRate, grossIncome, netIncome, schoolAmount, bondsAmount;
double clothesAmount, parentsBondsAmount, hoursWorked;

const double TAX_RATE = 0.14;


const double CLOTHES_PERCENTAGE_OF_INCOME = 0.10;
const double SCHOOL_PERCENTAGE_OF_INCOME = 0.01;
const double SAVINGS_BONDS_PERCENTAGE_OF_INCOME = 0.25;
const double PARENTS_CO_CONTRIBUTION_AMOUNT = 0.50;

cout << "How many hours did you work: ";


cin >> hoursWorked;

cout << "What was the hourly rate: $";


cin >> payRate;

grossIncome = hoursWorked * payRate;


netIncome = grossIncome *= TAX_RATE;
clothesAmount = netIncome * CLOTHES_PERCENTAGE_OF_INCOME;
schoolAmount = netIncome * SCHOOL_PERCENTAGE_OF_INCOME;
netIncome -= (clothesAmount + schoolAmount); // Calculate what is now left
bondsAmount = netIncome *
SAVINGS_BONDS_PERCENTAGE_OF_INCOME;
parentsBondsAmount = bondsAmount *
PARENTS_CO_CONTRIBUTION_AMOUNT;

cout << "Gross Income: $" << grossIncome << endl;


cout << "Net Income: $" << netIncome << endl;
cout << "Clothes & Accessories: $" << clothesAmount << endl;
cout << "School Supplies: $" << schoolAmount << endl;
cout << "Savings Bonds: $" << bondsAmount << endl;
cout << "Parents Bonds Co-Contribution: $" <<parentsBondsAmount << endl;

return 0;
}
Q#2.24
#include <iostream>

using namespace std;

int main(int argc, char** argv)


{
double lengthofwire,lengthofFrame,widthofFrame;
cout<<"enter the length of wire:";
cin>>lengthofwire;
widthofFrame=lengthofwire/5;
lengthofFrame=1.5*widthofFrame;
cout<<"length of the picture frame:"<<lengthofFrame<<endl;
cout<<"width of the picture frame:"<<widthofFrame<<endl;

return 0;
}
Q#2.26

#include <iostream>

using namespace std;

int main()
{
double
area,area1,area2,area3,area4,lengthdoor,widthdoor,lengthwindow,widthwindow,le
ngthbook,widthbook,lengthroom,widthroom,heightroom;
cout<<"enter the length of door:";
cin>>lengthdoor;
cout<<"enter the width of door:";
cin>>widthdoor;
cout<<"enter the length of window:";
cin>>lengthwindow;
cout<<"enter the width of window:";
cin>>widthwindow;
cout<<"enter the length of book:";
cin>>lengthbook;
cout<<"enter the width of book:";
cin>>widthbook;
cout<<"enter the length of room:";
cin>>lengthroom;
cout<<"enter the width of room:";
cin>>widthroom;
cout<<"enter the height of room:";
cin>>heightroom;
area1=lengthdoor*widthdoor;
area2=lengthwindow*widthwindow;
area3=lengthbook*widthbook;
area4=lengthroom*widthroom*heightroom;
area=area1+area2+area3+area4;
cout<<"total area"<<area<<endl;
cout<<"the amout of paint gallons are "<<area/120<<endl;

return 0;
}

You might also like