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
In a Java Script language. create a two-dimension array consisting of numbers representing costs. After creating the array, prin
Tanzania [10]

Answer:

Can you elaborate more?

Explanation:

5 0
3 years ago
To implement the various placement algorithms discussed for dynamic partitioning (see Section 7.2 ), a list of the free blocks o
STatiana [176]

Answer:

Check the explanation

Explanation:

Consider the following data

Let S represent the average number of segments

Let H represent the average number of holes

The probability that there is a hole immediately after the segment is 0,

So, when there are s segments in memory, there must be

s X 0.5 or \frac{s}{2}

Best-fit: this analyses the entire memory partitions available

a. you’ll have to selects the least one which is capable of handling the process exec.. Memo, space wastage .n be reduced In some cases, there will be no memory wastage

The average length a search is \frac{s}{2}

First-fit: This technique assigns Me the first hole that is big enough.

Searching Marts at the starting of Me set of holes.

The searching will be closed immediately a user gets a free hole that is big enough.

On an average it searches half of the set of holes.

The average length of search is Y2

\frac{s/2}{2} = \frac{s}{4}

5 0
3 years ago
Which element is located on the top left of the Word screen?
victus00 [196]
The <span>element located on the top left of the Word screen is the Quick Access Toolbar.  </span>On the quick access toolbar, you can find some of the common functions that you will need to use on a regular basis, it contains commands that are used most often, for example Redo, Undo and Save etc.
7 0
2 years ago
what are some of the challenges that could arise from setting up a file management system on a computer
seropon [69]
A virus maybe or ransomware
7 0
3 years ago
Write an if/else statement that compares the double variable pH with 7.0 and makes the following assignments to the int variable
levacccp [35]

Answer:

if (pH<7.0){

          neutral=0;

          base=0;

          acid=1;

      }

      else if (pH>7.0){

          neutral=0;

          base=1;

          acid=0;

      }

      else if (pH==7.0){

          neutral=1;

          base=0;

          acid=0;

      }

Explanation:

As required by the question, if and else statements have been used to test the value of the pH and assign the apropriate values to the variables neutral, base and acid.

The code snippet below can be used to prompt the user to enter values for pH

<em>import java.util.Scanner;</em>

<em>public class pHTest {</em>

<em>   public static void main(String[] args) {</em>

<em>      Scanner scr = new Scanner(System.in);</em>

<em>       System.out.println("Enter a value for the pH");</em>

<em>       int neutral, base, acid;</em>

<em>       double pH = scr.nextDouble();</em>

<em> if (pH<7.0){</em>

<em>           neutral=0;</em>

<em>           base=0;</em>

<em>           acid=1;</em>

<em>       }</em>

<em>       else if (pH>7.0){</em>

<em>           neutral=0;</em>

<em>           base=1;</em>

<em>           acid=0;</em>

<em>       }</em>

<em>       else if (pH==7.0){</em>

<em>           neutral=1;</em>

<em>           base=0;</em>

<em>           acid=0;</em>

<em>       }</em>

<em>} }</em>

4 0
3 years ago
Read 2 more answers
Other questions:
  • Judy forgot where she saved a certain file on her computer. Therefor, she searches for all files with a jpg file extension. Whic
    11·2 answers
  • What does software alone enable a computer to do? connect to the Internet control processing speeds interact with the user manag
    11·2 answers
  • My computer have black spots and line
    7·2 answers
  • Hi I am Khine Mye and I want to ask you a question I don't know that is square root of 2 is 1.4 and how to get that 1.4 and plz
    8·1 answer
  • What are 2 main differences betweenarrays andstructs?
    7·1 answer
  • Who found the first computer bug in 1947, and invented the concept of a compiler in 1952
    6·1 answer
  • Converting Denary to Binary
    15·1 answer
  • Only need help on f and correct me if im wrong for the other questions please
    11·1 answer
  • How would you delete a slide from your presentation after selecting it?
    14·1 answer
  • If u play codm pls tell me ur username
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!