Quantcast

A community for students. Sign up today!

Here's the question you clicked on:

55 members online
  • 0 replying
  • 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)

  • This Question is Closed
  1. JadeEyes
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    The 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*(time-hour); <----- 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++.

  2. compute
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 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; }

  3. JadeEyes
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Thank you again...!! :) ..!!

  4. compute
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 2

    its k...

  5. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Ask a Question
Find 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
  • 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.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.