Using Java 1 Calls a method that displays 2 lines of welcomi
Using Java
1. Calls a method that displays 2 lines of welcoming and letting the user know what this program is about. You choose the wording.
A. The method will return no value.
2. Calls a method that requests your department name and returns a string (saving that string to a variable)
3. Calls a method that requests your manager\'s name and returns a string (saving that string to a variable)
4. Calls a method that requests the purpose of the trip.
A. 1 = Sales 2 = training
B. Make sure the request makes it very clear what the 1 & 2 indicate.
C. Whatever the user chooses, will be saved to a variable. You decide whether the method will return a string or an integer.
5. If the user chooses 1
A. Call a method that requests the quantity of miiles traveled for the purpose of sales, and returns an integer (saving that integer to a variable)
B. Calls a method that takes that quantity of miles (from A) and multiplies it to $2.25 to get the mileage pay. This method returns that pay as double, being saved to a variable.
6. If the user chooses 2
A. Call a method that requests the quantity of miles traveled for the purpose of training, and returns an integer (saving that integer to a variable)
B. Calls a method that takes that quantity of miles (from A) and multiplies it to $1.25 to get the mileage pay. This method returns that pay as double, being saved to a variable.
7. If the user chooses something other than 1 or 2
A. Call a method that will output a message to the screen indicating that they chose a value that wasn\'t valid.
B. Make sure that the milage pay = $0 and the quantity of miles = 0.
8. Finally, call a method that takes the following as arguments:
A. Department name
B. Manager Name
C. Purpose of Travel (1, 2, or nothing - or you could say sales, training, or nothing)
D. Mileage Pay
This method wont return a value, it will just output information to the screen.
Using the values of its arguments, display a line or two (use all 4 of the arguments) to display the resulting mileage pay for the specified travel purpose, for the specified department, managed by the specified manager.
Solution
import java.io.BufferedReader;
public class Test
{
private string dept_name;
private string manager_name;
private int choice;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int i = Integer.parseInt(br.readLine());
public string getDeptName()
{
System.out.println(\"Please enter the Department\'s name\ \");
dept_name = br.readLine();
return dept_name;
}
public string getManagerName()
{
System.out.println(\"Please enter your Manager\'s name\ \");
manager_name = br.readLine();
return manager_name;
}
public int getChoice()
{
System.out.println(\"Please Enter your Choice:\ 1 = Sales\ 2 = Training\")
choice = Integer.parseInt(br.readLine());
return choice;
}
public static void main(String args[])
{
Test t = new Test();
int choice;
t.getDeptName();
t.getManagerName();
choice = getChoice();
}
}

