A community for students.
Here's the question you clicked on:
 0 viewing
JadeEyes
 2 years ago
Write a program to calculate the estimated journey time of a train. The program should request and read the distance in miles and the average speed in miles per hour, and display the estimated journey time in hours and minutes to the nearest ninute.
Test your program with:
(a) Distance = 1.01, speed = 1.(Result should be 1 hour & 1 minute)
(b) Distance = 1.005, speed = 1.(Result should be 1 hour & 0 minute)
JadeEyes
 2 years ago
Write a program to calculate the estimated journey time of a train. The program should request and read the distance in miles and the average speed in miles per hour, and display the estimated journey time in hours and minutes to the nearest ninute. Test your program with: (a) Distance = 1.01, speed = 1.(Result should be 1 hour & 1 minute) (b) Distance = 1.005, speed = 1.(Result should be 1 hour & 0 minute)

This Question is Closed

JadeEyes
 2 years ago
Best ResponseYou've already chosen the best response.0The codes I entered: #include<iostream.h> #include<stdio.h> int main () { float distance,speed,time; int hour,minute; printf("Enter Distance Of Journey(in miles):\n"); scanf("%f",&distance); printf("Enter Average Speed Of Train(in miles per hour):\n"); scanf("%f",&speed); time = distance/speed; hour = distance/speed; minute = 60*(timehour); < Problem here : For any value minutes=zero printf("Approximate Journey Time: %d hour and %d minutes.\n",hour,minute); system("pause"); return 0; } Can anyone help me resolve this problem? I'm using Dev C++.

compute
 2 years ago
Best ResponseYou've already chosen the best response.2#include<stdio.h> int main () { float distance,speed,time,minute; int hour,min; printf("Enter Distance Of Journey(in miles):\n"); scanf("%f",&distance); printf("Enter Average Speed Of Train(in miles per hour):\n"); scanf("%f",&speed); time = distance/speed; minute = 60*time; if(minute>=60) { hour=minute%60; min=minute/60; } printf("Approximate Journey Time: %d hour and %d minutes.\n", hour,min); system("pause"); return 0; }

JadeEyes
 2 years ago
Best ResponseYou've already chosen the best response.0Thank you again...!! :) ..!!
Ask your own question
Sign UpFind more explanations on OpenStudy
Your question is ready. Sign up for free to start getting answers.
spraguer
(Moderator)
5
→ View Detailed Profile
is replying to Can someone tell me what button the professor is hitting...
23
 Teamwork 19 Teammate
 Problem Solving 19 Hero
 Engagement 19 Mad Hatter
 You have blocked this person.
 ✔ You're a fan Checking fan status...
Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.