0% found this document useful (0 votes)
30 views3 pages

#Include #Include: Using Namespace Int Float

The document contains 5 coding assignments in C++ with increasing levels of complexity. The first assignment calculates speed from distance and time. The second calculates the cost of a phone call given start and end times. The third generates a table comparing costs of different types of gasoline over a given distance. The fourth calculates hours, minutes and seconds passed and remaining in a day. The fifth simply calculates hours remaining in a work day given elapsed time. All include input, output and basic math operations to solve applied problems.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views3 pages

#Include #Include: Using Namespace Int Float

The document contains 5 coding assignments in C++ with increasing levels of complexity. The first assignment calculates speed from distance and time. The second calculates the cost of a phone call given start and end times. The third generates a table comparing costs of different types of gasoline over a given distance. The fourth calculates hours, minutes and seconds passed and remaining in a day. The fifth simply calculates hours remaining in a work day given elapsed time. All include input, output and basic math operations to solve applied problems.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Домашнее задание

Задание №1
#include <iostream>
#include <math.h>

using namespace std;

int main()
{
float distance, time, speed;
cout << "Count speed to get to the airport\n";
cout << "\n====================================================\n";
cout << "\nInput distance to the airport in km\n\n";
cin >> distance;
cout << "\nInput the time to get there in hours\n\n";
cin >> time;
speed = distance / time;
cout << "\nYou need to move at speed " << speed << " km/hour\n";
cout << "\n====================================================\n";
cout << "\nCreated by Sylka Danylo\n";
return 0;
}

Задание №2
#include <iostream>
#include <math.h>

using namespace std;

int main()
{
float timestarth, timestartm, timestarts, timeendh, timeendm, timeends, timeh, timem,
times, cost;
const float costmin = 0.3;
cout << "Count price of the conversation if it costs 30 kop/min\n";
cout << "\n====================================================\n";
cout << "\nInput the time when conversation has started (hours minutes seconds)\n\n";
cin >> timestarth >> timestartm >> timestarts;
cout << "\nInput the time when conversation has ended (hours minutes seconds)\n\n";
cin >> timeendh >> timeendm >> timeends;
timeh = timeendh - timestarth;
timem = timeendm - timestartm;
times = timeends - timestarts;
cost = (timeh * 60 * costmin) + (costmin * timem) + (times / 60 * costmin);
cout << "\nThe cost of the conversation = " << cost << " grn.kop\n";
cout << "\n====================================================\n";
cout << "\nCreated by Sylka Danylo\n";
return 0;
}

Задание №3
#include <iostream>
#include <math.h>

using namespace std;

int main()
{
float AI92, AI95, AI98, distance, AI92_100, AI95_100, AI98_100;
cout << "Table of travel cost for different types of gasoline (AI92, AI95, AI98)\n";
cout << "\n=================================================\n";
cout << "\nInput distance in km\n\n";
cin >> distance;
cout << "\nInput cost of AI92 on 100 kilometers (grn.kop)\n\n";
cin >> AI92_100;
cout << "\nInput cost of AI95 on 100 kilometers (grn.kop)\n\n";
cin >> AI95_100;
cout << "\nInput cost of AI98 on 100 kilometers (grn.kop)\n\n";
cin >> AI98_100;
AI92 = AI92_100 * (distance / 100);
AI95 = AI95_100 * (distance / 100);
AI98 = AI98_100 * (distance / 100);
cout << "\n=================================================\n";
cout << "|\t\bAI92\t|\t\bAI95\t|\t\bAI98\t|\n";
cout << "| " << AI92 << "grn.kop\t| " << AI95 << "grn.kop\t| " << AI98 << "grn.kop\t|";
cout << "\n=================================================\n";
cout << "\nCreated by Sylka Danylo\n";
return 0;
}

Задание №4
#include <iostream>
#include <math.h>

using namespace std;

int main()
{
int secondsstart, hours, minutes, seconds, hoursleft, minutesleft, secondsleft;
const int allday = 24 * 3600;
cout << "How much time has passed and how much is left\n";
cout << "\n====================================================\n";
cout << "\nInput how many seconds have passed\n\n";
cin >> secondsstart;
hours = secondsstart / 3600;
minutes = secondsstart / 60 % 60;
seconds = secondsstart % 3600 % 60;
secondsstart = allday - secondsstart;
hoursleft = secondsstart / 3600;
minutesleft = secondsstart / 60 % 60;
secondsleft = secondsstart % 3600 % 60;
cout << "\n====================================================\n";
cout << "\nIn total, " << hours << " hours " << minutes << " minutes and " <<seconds<<"
seconds passed\n\n";
cout << "And " <<hoursleft << " hours " << minutesleft << " minutes and " << secondsleft
<< " seconds left until midnight\n";
cout << "\n====================================================\n";
cout << "\nCreated by Sylka Danylo\n";
return 0;
}

Задание №5
#include <iostream>
#include <math.h>

using namespace std;

int main()
{
int secondsstart, hoursleft;
const int workday = 8 * 3600;
cout << "How much time left until the end of work\n";
cout << "\n====================================================\n";
cout << "\nInput how many seconds have passed\n\n";
cin >> secondsstart;
secondsstart = workday - secondsstart;
hoursleft = secondsstart / 3600;
cout << "\n====================================================\n";
cout << "\nThere is " << hoursleft << " hours left until the end of work\n";
cout << "\n====================================================\n";
cout << "\nCreated by Sylka Danylo\n";
return 0;
}

You might also like