samedi 5 juillet 2014

Calculate user input and printf()


Vote count:

0




this is my code so far.



import java.util.*;
public class one {

public static void main(String[] args) {
System.out.println("--- Stage 1 Taxi Fare Calculator ---");

Scanner user_input = new Scanner( System.in );
String start_time;
System.out.print("Enter in pick up time: ");
start_time = user_input.next();

String pick_up;
System.out.print("Enter in pickup point: ");
pick_up = user_input.next();

String drop_off;
System.out.print("Enter in drop off point: ");
drop_off = user_input.next();

Double trip_dist;
System.out.print("Enter in trip distance in km: ");
trip_dist = user_input.nextDouble();

System.out.println(" --- Taxi fare details --- ");

String m1 = "Pickup point: ";
String m2 = "Drop off point: ";
String m3 = "Pickup time: ";
String m4 = "Estimated distance (km): ";
String m5 = "Fare Charged: $";
String m6 = "Base fare: $";
String m7 = "Total fare: $ ";



}


}


So what I have so far is the program asking the user for input and storing them. What I am having troubles with is using that user input and using printf() to display the input with m1 - m7 strings. I also need to calculate the base fare which is base fare = trip distance * fare rate. I have been searching for a while now and just cant find anything to help me out. just wondering if anyone could offer some assistance. Thank you very much for your time.



asked 1 min ago






Aucun commentaire:

Enregistrer un commentaire