Computer Science for Everyone - 27 - User input in Java (programming video)

preview_player
Показать описание
Computer Science for Everyone - 27 - User input in Java (programming video)

"Computer Science for Everyone" is an online course that covers all of the most important concepts in computer science, from hardware, to algorithms, to programming and data structures.

In this video we look at how we can program our user input to make our program get data from the user.

I'm committed to providing free quality computer science education for everyone. Your help can make that happen!

Рекомендации по теме
Комментарии
Автор

Ok that´s a tough one. Have to rewatch this one

kebarius
Автор

Hello, there
could you help me ples?

I am trying to do a simple calculation. But when i run the file..I keep getting this in the console

"You were travelling at a speed of NaNm/s"

I seriously don't know where the 'Na' came from..
I seriously do not know why its not showing the speed like it should!

The below is the soucre code

import java.util.Scanner ;
public class Test {

public double time;
public double speed;
public double distance;



public void findingSpeed(double t, double d){
t = time ;
d = distance ;
speed = d/t ;
System.out.println("You were travelling at a speed of " + speed + "m/s");

}

public static void main(String[] args) {
Scanner reader = new Scanner(System.in);

System.out.println("Enter you trip distance.");
double inputd = reader.nextDouble() ;

System.out.println("Now enter your trip duration");
double inputt = reader.nextDouble() ;

Test calculating = new Test ();
calculating.findingSpeed(inputt, inputd);

malevip
welcome to shbcf.ru