Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. (30) Write a Java application named Hwl_1.java that reads your full name and

ID: 3891798 • Letter: 1

Question

1. (30) Write a Java application named Hwl_1.java that reads your full name and your major, and prints out the following message: (user full name) is a (user major) major Here is a sample of the program's behavior: Enter your full name: Tiep Le (user input) Enter your major: Computer Science (user input) (program output) Tiep Le is a Computer Science major. Note: In the sample above, the user needs to enter Tiep Le' when the user is asked Enter your full name: '. Then the user needs to enter Computer Science' when the user is asked Enter your major. After this, the program will print out to the console 'Tiep Le is a Computer Science major.' 2. (30) Write a Java application named Hw12.java that converts your home country currency to US dollars. Please check on the Internet for the rate. For American students, please convert from US dollars to Canadian dollars. Note: the program reads your currency value from the user as a floating-point value Ex: Converting from US dollars to Canadian dollars (1 US dollar 1.30 Canadian dollar). So if I want to convert 10 US dollars to Canadian dollars, it should be 10 * 1.30 13.0) Here is a sample of the program's behavior: Enter your home country currency amount: 10 (user input) 10 US dollars -13.0 Canadian dollars (program output)

Explanation / Answer

Hw1_1.java

import java.util.Scanner;

public class Hw1_1 {

public static void main(String[] args) {

Scanner scan = new Scanner(System.in);

System.out.println("Enter your full name: ");

String name = scan.nextLine();

System.out.println("Enter your major:");

String major = scan.nextLine();

System.out.println(name+" is a "+major);

}

}

Output:

Enter your full name:
Tiep Le
Enter your major:
Computer Science
Tiep Le is a Computer Science

Hw1_2.java

import java.util.Scanner;

public class Hw1_2 {

public static void main(String[] args) {

Scanner scan = new Scanner(System.in);

System.out.println("Enter your home country currency amount: ");

int amount = scan.nextInt();

System.out.println(amount+" US dollors = "+(1.3 * amount)+" Canadian dollors");

}

}

Output:

Enter your home country currency amount:
10
10 US dollors = 13.0 Canadian dollors