Computing.Net > Forums > Programming > C++ Help Needed

Computing.Net: Over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to sign up now, it's free!

C++ Help Needed

Reply to Message Icon

Original Message
Name: xsu
Date: September 24, 2002 at 18:04:04 Pacific
Subject: C++ Help Needed
OS:  
CPU/Ram:  
Comment:

Ok I need help with a program I need to make in programming class. I have most of it done already, but I'm missing something, if you guys could point me in the right direction. I have to do as follows:

I have to create a program that will calculate runner's time. Typical input would be as follows:

Runner number: 234
Mile times: 1 5:34.22
2 11:21.67
Finish time: 17:46.85

Typical output would be:

Runner number 234
Split one 5:34.22
Split two 5:47.45
Split three 6:25.18
Finish time 17:46.85

I got most of it done, but what I can't figure out is how to convert the input to the format it's in right here, with the colon and everything, when I run the program and get to that part it just messes up, and that's what I need help with. This is what I got so far:

//Manny Roldan#include #include #include int main(){ double time1, time2, time3; double split1, split2, split3; int rn; cout>rn; cout>time1; cout>time2; split1 = (time1-0); split2 = (time2-time1); split3 = (time3-time2); time3 = (time1+time2); cout<<"Runner Number"<I know I'm missing something, please help. Thanks in advance


Report Offensive Message For Removal


Response Number 1
Name: mumu
Date: September 24, 2002 at 20:36:55 Pacific
Reply: (edit)

You will need to split up the times into hours minutes and second for each runner...so for example

double runner1hour;
double runner1minute;
double runner1secs;

do this for each runner

then at output you output each runners time by outputting each unit of time split by colons that u insert manualy....

also you should get into the habit of outputting your data after you get it all in instead of mixing up your inputs and outputs....it makes it hard to read and should only be used when absolutly neccesary...


Report Offensive Follow Up For Removal

Response Number 2
Name: mumu
Date: September 25, 2002 at 15:40:10 Pacific
Reply: (edit)

gotta love it when you do someones homework for them and they dont even bother to tell you if it helped em....warning: this is a sign that you may not pass your class......


Report Offensive Follow Up For Removal

Response Number 3
Name: cmath
Date: October 1, 2002 at 10:03:20 Pacific
Reply: (edit)

try the cin.ignore() for the keyboard to ignore the ":" ...


Report Offensive Follow Up For Removal







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home








Do you own an iPhone?

Yes
No, but soon
No


View Results

Poll Finishes In 7 Days.
Discuss in The Lounge
Poll History




Data Recovery Software