Im using pythn 3.4.2 and the question is from while loop and for loop chapters f
ID: 675070 • Letter: I
Question
Im using pythn 3.4.2 and the question is from while loop and for loop chapters
for example, it a train travels 40 miles per hour for three hours, the distance traveled is 120 miles. design a program that asks the user for the speed of a vehicle( in miles per hour) an how many hours it has traveled. it should then use a loop to display the distance the vehicle has traveled for each hour of that time period. Here is an example of the out put what is the speed of vehicle in mph? 40 [enter] how many hours has it traveled? 3[enter]
Hour distance traveled
1 40
2 80
3 120
Explanation / Answer
import java.util.Scanner; public class Distance{ public static void main(String [] args){ Scanner keyboard = new Scanner(System.in); int time , speed , hour; double distance; System.out.println("How fast were you going ?"); speed = keyboard.nextInt(); while(speedRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.