15.8k views
3 votes
Write a C++ program that displays the total running time of a given algorithm based on

different situations such as processor speed, input size, processor load, and software
environment (DOS and Windows).

User Mclaughj
by
6.7k points

1 Answer

3 votes

Answer: Your welcome!

Step-by-step explanation:

#include <iostream>

#include <cmath>

using namespace std;

int main()

{

int processorSpeed; //in MHz

int inputSize; //in Kb

int processorLoad; //in %

int softwareEnvironment; //1: DOS, 2: Windows

int runningTime; //in ms

cout << "Enter processor speed (MHz): ";

cin >> processorSpeed;

cout << "Enter input size (Kb): ";

cin >> inputSize;

cout << "Enter processor load (%): ";

cin >> processorLoad;

cout << "Enter software environment (1-DOS, 2-Windows): ";

cin >> softwareEnvironment;

if(softwareEnvironment == 1)

{

//DOS running time calculation

runningTime = (inputSize / processorSpeed) + (processorLoad / 10);

}

else

{

//Windows running time calculation

runningTime = (inputSize / (processorSpeed/2)) + (processorLoad / 10);

}

cout << "Total running time: " << runningTime << "ms" << endl;

return 0;

}

User Shirlee
by
7.1k points