1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
nydimaria [60]
3 years ago
11

Write a well-commented Java program that answers the following questions in complete sentences such that the reader does not hav

e to know the question in advance. Use either System.out methods or JOptionPane for your program output:
Computers and Technology
1 answer:
pickupchik [31]3 years ago
6 0

Answer:

import java.util.Scanner;

import javax.swing.JOptionPane;

public class labExercise1

{

public static void main(String[] args)

{

int sum= 0;

double interestRate = 5.0;

double monthlyPayment=0;

double totalPayment=0;

String input = JOptionPane.showInputDialog(null,"Enter the loan amount: ($)","Lab Exercise 1", 2);

double loanAmount = Double.parseDouble(input);

String input1 = JOptionPane.showInputDialog(null,"Enter the loan period(years):","Lab Exercise 1",2);

double numberOfYears = Double.parseDouble(input1);

JOptionPane.showConfirmDialog(null,"The loan amount is $" + loanAmount + ", and the loan duration is " + numberOfYears + "year(s). Continue?","Lab Exercise 1",2);

String s1 = null;

System.out.print("Interest Rate(%) Monthly Payment($) Total Payment($) ");

s1 = "Interest Rate(%) Monthly Payment($) Total Payment($) ";

while (interestRate <= 8.0)

{

double monthlyInterestRate = interestRate / 1200;

monthlyPayment= loanAmount * monthlyInterestRate / (1 - 1 / Math.pow(1 + monthlyInterestRate, numberOfYears * 12));

totalPayment = monthlyPayment * numberOfYears * 12;

s1 = s1 + String.format("%.3f%30.2f %40.2f ",interestRate, monthlyPayment, totalPayment) + " ";

System.out.println(s1);

interestRate = interestRate + 1.0 / 8;

}

//s1 = String.format("%16.3f%19.2f%19.2f ",interestRate, monthlyPayment, totalPayment);

System.out.println(s1);

JOptionPane.showMessageDialog(null,s1,"Lab Exercise 1",3);

}

}

Explanation:

  • Take the loan amount and period as inputs from the user.
  • Calculate the monthly interest rate by dividing the interest rate with 1200.
  • Calculate total payment using the following the formula:
  • totalPayment = monthlyPayment * numberOfYears * 12;
You might be interested in
What is a digital pen called<br><br>A digital pen is called a ____
steposvetlana [31]
A digital pen is a battery-operated writing instrument that allows the user to digitally capture a handwritten note or drawing. Typically, a digital pen comes with a Universal Serial Bus (USB) cradle to let the user upload the handwritten notes to a personal computer (PC).

Sometimes called a smart pen or stylus.
4 0
3 years ago
Read 2 more answers
Mary is proofreading an eBook. Sometimes she has to scroll several pages at a time. Which key on the numeric keypad will help he
Leto [7]
The number key 2 will help her scroll down.
3 0
3 years ago
Read 2 more answers
A customer has a system with a Gigabyte B450 Aorus Pro motherboard. He wants to upgrade the processor from the AMD Athlon X4 950
AleksandrR [38]
This upgrade will make a big improvement from his AMD Athalon X4 950 to the AMD Ryzen 7 2700X this is because the system will have more gigabytes and a better processor
3 0
3 years ago
Read 2 more answers
Write a pseudo code to print sum of all even numbers from 1 to 100
Vinil7 [7]

(python) Answer:

sum = 0

for i in range 1 to 101:

 if i modulo 2 == 0:

   sum += i

print(sum)

Explanation:

first we declare the sum variable

then go through all numbers 1 through 100 (range 1 to 101 because python range does not include the last number - if we did 1 to 100 it would look at 1 to 99)

if the number is even (divide by 2, check if there's a remainder, if not it's even and we will add the number to the sum

finally print the sum

5 0
2 years ago
What are two composite numbers that both have 8 as a factor?
Vinvika [58]
A composite number is a number that can be divided by a number other than one and itself.
Composite numbers with 8 as a factor:
16, 24, 32, 40, 48.
Choose two of the numbers.
6 0
3 years ago
Other questions:
  • Assume that word is a variable of type String that has been assigned a value. Assume furthermore that this value always contains
    13·2 answers
  • For a loop counter, the appropriate data type would be:
    14·1 answer
  • What is out put.what is data. what is microprocessor
    14·1 answer
  • The smallest building block of a wireless lan is a ______.
    5·1 answer
  • This function receives first_name and last_name, then prints a formatted string of "Name: last_name, first_name" if both names a
    5·1 answer
  • Write a Java program to count the characters in each word in a given sentence?Examples:Input : geeks for geeksOutput :geeks-&gt;
    10·1 answer
  • Computers are designed with what type of memory?
    13·1 answer
  • What is the smallest amount of information called?
    13·2 answers
  • Why is there no window on dishwsher
    13·2 answers
  • 4. What is the formula for calculating the file size?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!