Answer:
import java.util.Scanner;
public class HelloIDE
{
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Enter your name: ");
String name = input.nextLine();
name = name.trim();
if(name.equals(""))
name = "stranger";
System.out.println("Hello, " + name + "!");
}
}
Explanation:
import the Scanner class to be able to get input from the user
Create an object of the Scanner class called input
Ask the user to enter the name and set it to the name
Trim the name using trim() method, removes the whitespaces from the string
Check the name. If name is equal to "", set the name as stranger. This way if the name is empty, or just contains whitespaces or if name is not given, name will be set as stranger.
Print the name in required format
Answer:
current_price = int(input())
last_months_price = int(input())
change = current_price - last_months_price
mortgage = (current_price * 0.051) / 12
print('This house is $' + str(current_price) + '. The change is $' + str(change) + ' since last month.')
print('The estimated monthly mortgage is ${:.2f}.'.format(mortgage))
Explanation:
Ask the user to enter the current price and last month's price
Calculate the change, subtract last month's price from the current price
Calculate the mortgage using the given formula
Print the results in required format
Answer:
It is a C++ program. The complete function ConvertToDecadesAndYears which takes totalYears as parameter and convert totalYears to decades and years is provided in the attached document.
Explanation:
The explanation is provided in the attached document.
The screenshot of the complete code along with its output is attached.
Answer: The amount of interest to be paid is $972
Explanation: This is gotten by firstly getting the amount of money to return per year without the interest which is $114400/10(years)= 11440
11440 is to be paid per year without interest. To get amount of interest is $11440*8.5/100 = $972 this is the amount of interest to be paid per year including in year 2.
Therefore, total amount of money together with interest to be paid each year and in year 2 = $11440+$972=12412.