Write an algorithm to decide which is cheaper car or bus


3.1 Write an Algorithm to decide which is cheaper car or bus for a travel:

You want to decide whether you should drive your car to work or take the bus. You know the one-way distance from your home to your place of work, and the fuel efficiency of your car (in miles per gallon). You also know the one-way price of a train ticket. You assume the cost of gas at $4 per gallon, and car maintenance at 5 cents per mile. Write an algorithm to decide which commute is cheaper.

3.2 Use string concatenation only to complete the following program so that it prints the message "the quick white tiger jumps over the small dog".
public class ConcatDemo
{
public static void main(String[] args)
{
String animal1 = "quick white tiger"; String animal2 = "small dog";
String article = "the"; String action = "jumps over";
/* Your work goes here */
System.out.println(message);
}
}
3.3 Find the output of the following code when the user enters 100 and when the user enters AQ:
public static void main(String[] args)
{
Scanner in = new Scanner(System.in); System.out.print("Enter somthing: "); String str = in.next();
int count = Integer.parseInt(str); System.out.println("Input is " + count);
}

Request for Solution File

Ask an Expert for Answer!!
Basic Computer Science: Write an algorithm to decide which is cheaper car or bus
Reference No:- TGS01463296

Expected delivery within 24 Hours