grodek118

Distanced Traveled

Nov 11th, 2022
872
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.68 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.io.*;
  4. import java.util.Scanner;
  5.  
  6. public class Main {
  7.  
  8.     public static void main(String[] args) throws IOException {
  9.  
  10.       Scanner scanner = new Scanner(System.in);
  11.  
  12.       int speed;
  13.       int time;
  14.  
  15.       System.out.print("Please, give speed of the vehicle: ");
  16.       speed = scanner.nextInt();
  17.       System.out.print("Now time it took to get to the destination: ");
  18.       time = scanner.nextInt();
  19.  
  20.       System.out.println("Hour\tDistance Traveled");
  21.       System.out.println("----------------------------");
  22.  
  23.       for (int i = 1; i <= time; i++)
  24.       {
  25.  
  26.         System.out.println(i + "\t\t\t\t" + (i * speed));
  27.  
  28.       }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment