[ create a new paste ] login | about

Link: http://codepad.org/v5QXm55L    [ raw code | output | fork ]

C++, pasted on Mar 21:
//  Created by Myratgeldi Bekdurdyyev on 10/12/16.

/*programmer:myratgeldi bekdurdyyev
 description:In this program you will be asked for three runners',
 name and the time it took for each of them and then display who came first , second and last.
 */

#include<iostream>
#include<string>
using namespace std;

int main() {
    string  name1,name2,name3;
    double time1,time2,time3;
    cout << "Today you will be asked for three runner's  name\n";
    cout<<"and time they took to finish the race" << endl;
    
    cout << "Please enter the first runner's name:" << endl;
    getline(cin, name1);
    cout << "Now please Enter the time that first runner took(1-12)" << endl;
    cin >> time1;
    cin.ignore();
    
    cout << "Please enter the second runner's name:" << endl;
    getline(cin, name2);
    cout << "Now please Enter the time that second runner took(1-12)" << endl;
    cin >> time2;
    cin.ignore();
    
    cout << "Please enter the third runner's name:" << endl;
    getline(cin, name3);
    cout << "Now please Enter the time that  third runner took(1-12)" << endl;
    cin >> time3;
    
    if(time1<=0 && time1>=4){
        cout<<name1<<" came first"<<endl;}
    else if(time1<=5 && time1>=8){
        cout<<name1<<" came second"<<endl;}
    else if(time1<=9 && time1>=12){
        cout<<name1<<" came last"<<endl;}
    
    if(time2<=0 && time2>=4)
        cout<<name2<<" came first"<<endl;
    else if(time2<=5 && time2>=8)
        cout<<name3<<" came second"<<endl;
    else if(time2<=9 && time2>=12)
        cout<<name2<<" came last"<<endl;
    
    if(time3<=0 && time3>=4)
        cout<<name3<<" came first"<<endl;
    else if(time3<=5 && time3>=8)
        cout<<name3<<" came second"<<endl;
    else if(time3<=9 && time3>=12)
        cout<<name3<<" came last"<<endl;
    
    
    
    
    
    return 0;
}


Output:
1
2
3
4
5
6
7
8
Today you will be asked for three runner's  name
and time they took to finish the race
Please enter the first runner's name:
Now please Enter the time that first runner took(1-12)
Please enter the second runner's name:
Now please Enter the time that second runner took(1-12)
Please enter the third runner's name:
Now please Enter the time that  third runner took(1-12)


Create a new paste based on this one


Comments: