I am currently taking a course on C++ and struggling with it so bad. Can anybody help me out with this program? I suppose to calculate a time difference, but my problem is the compiler keeps giving me an error, that i don't know how to fix. Can anybody help, is my program correct? thank you so much!
#include <iostream>
using namespace std;
int do_math(int hour_now, int minute_now, int now_time, int hour_future, int minute_future, int future_time);
bool good_choice(char AP);
int main (){
int hour_now, minute_now, now_time, hour_future, minute_future, future_time, total_minutes;
cout<<"This machine calculates the time difference, enter time in hours, minutes and enter am or pm"<<endl;
cout<<"Enter present time"<<endl;
cin>>hour_now;
cin>>minute_now;
cin>>now_time;
cout<<"Enter the future time"<<endl;
cin>>hour_future;
cin>>minute_future;
cin>>future_time;
time2.cpp: In function int do_math(int, int, int, int, int, int):
time2.cpp:36: warning: the address of bool good_choice(char) will always evaluate as true
time2.cpp:51: error: else without a previous if
time2.cpp:67: error: expected primary-expression before || token
time2.cpp:69: error: else without a previous if (this is the last else before the return false)
I don't see why they are wrong. That's why i am confused...
ya i'm workin hard on this. I did notice the bool was messed up. i think I almost got it (even tho i basically rewrote the whole thing.
just notice that"now_time and future_time" are initiated as integers when there actually an array of characters............ so maybe you should start there.
I'm sorry English is not my first language. What does it mean? Do i messed up the whole thing including the time conversion formula? Or is it just my loops structure and boolean usage are wrong?
The planned to use boolean this way:
if the user input A for AM for the current time and input A for the future time then bool is true (same goes for P for PM for both now time and future time). Else wrong.
That means i have to declare char for the boolean i gues...
I'm sorry for making you working so hard on this... thank you :)
ok well I'm actually gettin ready to go to bed but i'll share with you what I've come up with so far and you can change it play with it ect.
I just got this to run with no errors but my first test it returned a zero....... so there obviously somekinda mistake in here some where. But listen To make this simplier I basically used "am" as default and "pm" as now_time + 12 to use it like military time. just made it easier for me to wrap my mind around. heres my code good luck. Remeber I'm a noob myself so I'm deffinetly not perfect but I changed it alot