Would you like to react to this message? Create an account in a few clicks or log in to continue.

Llogarit Shpejtesin.... C++

Shko poshtë

Llogarit Shpejtesin.... C++ Empty Llogarit Shpejtesin.... C++

Mesazh nga floroS Sat Sep 26, 2009 1:26 am

Programi i meposhtem llogarit shpejtesine mesatare, distancen dhe kohen per sa keni vrapuar nje milje(per ata qe vrapojne)

Kodi:
#include <iostream>
#include <iomanip>
using namespace std;
int main ()
{
float laps, time, speed, distance, aver;
cout << fixed<< setprecision(2);
cout <<"Enter the number of laps you run \n" ;
cin >> laps;
cout << "Enter the time of your run in seconds \n";
cin >> time;
distance=0.1456439 *laps;
speed=distance/3600*time;
aver=distance/60*time;
cout <<"Your total run length for today is " <<distance<< "miles. \n";
cout <<"You have been running with the speed of " <<speed<< "mph. \n";
cout <<"You runned a mile in " <<aver<< "minutes. \n";
return 0;
}

Kodi:

#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int value=1, counter=1, cof=0, tea=0, oj=0, lem=0;
float perc1, perc2, perc3, perc4 ;
while (value!=5)
{cout<<"\nEnter your choice. Press: \n 1 for Coffee, 2 for Tea, 3 for Orange Juice, 4 for Lemonade or press 5 to quit."<<endl;
cin>>value;
switch (value)
{
case 1: cof++;
break;
case 2: tea++;
break;
case 3: oj++;
break;
case 4: lem++;
break;
case 5: cout<<"You just decided to quit\n.";
break;
default: cout<< "Please enter a valid number 1, 2, 3, 4 or 5. Your choice will not be considered.";
break;
}
counter++;
}
cout<<fixed<<setprecision(2);
perc1 =cof*100/(counter-2);
perc2 =tea*100/(counter-2);

perc3 =oj*100/(counter-2);
perc4 =lem*100/(counter-2);
counter=counter-2;
cout<< "The total number of persons that have been surveyed is " <<counter<<endl;
cout<<"The results of the survey: "<<endl;
cout<<setw(20)<<"Beverage chosen"<<setw(20)<<"Number of votes"<<setw(21)<<"Percentage"<<endl;
cout<<"-------------------------------------------------------------------------------"<<endl;
cout<<setw(20)<<"Coffee"<<setw(20)<<cof<<setw(20)< <perc1<<"%"<<endl;
cout<<setw(20)<<"Tea"<<setw(20)<<tea<<setw(20)<<pe rc2<<"%"<<endl;
cout<<setw(20)<<"Orange Juice"<<setw(20)<<oj<<setw(20)<<perc3<<"%"<<endl;
cout<<setw(20)<<"Lemonade"<<setw(20)<<lem<<setw(20 )<<perc4<<"%"<<endl;
return 0;
}
floroS
floroS
WebMaster
WebMaster

Numri i postimeve : 1981
Age : 30
Location : Milkyway
Registration date : 12/03/2009

http://htttp://youtube.com/floros93

Mbrapsht në krye Shko poshtë

Mbrapsht në krye


 
Drejtat e ktij Forumit:
Ju nuk mund ti përgjigjeni temave të këtij forumi