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 this problem, there will be the construction of a program that reads in a sequence of integers from standard input until 0 is
Sedaia [141]

Answer:

Check the explanation

Explanation:

package util;

import java.util.ArrayList;

import java.util.Iterator;

import java.util.List;

import java.util.Scanner;

public class Assignment9 {

public Assignment9() {

List<Integer> numList = new ArrayList<Integer>();

Scanner sc = new Scanner(System.in);

System.out.println("Please enter the numbers , press 0 to stop");

int x = 0;

do {

x = sc.nextInt();

numList.add(x);

} while (x != 0);

int size = numList.size();

Integer[] numArray = new Integer[size];

Iterator<Integer> it = numList.iterator();

int i = 0;

while (it.hasNext()) {

numArray[i] = it.next();

i++;

}

int min = findMin(numArray, 0, 2);

System.out.println("The minimum number is " + min);

int sum = computeNegativeSum(numArray, 0, 2);

System.out.println("The sum of the negative numbers is " + sum);

int sumOdd = computeSumAtOdd(numArray, 0, 3);

System.out

.println("The sum of the numbers at odd indexes is " + sumOdd);

int countEven = computeCountEven(numArray, 0, 3);

System.out.println("The total count of even integers is " + countEven);

}

/**

* This method is used to compute the minimum number

* "at"param NumArray

* "at"param startIndex

* "at"param endIndex

* "at"return

*/

public int findMin(Integer[] NumArray, int startIndex, int endIndex) {

if (startIndex == endIndex)// base case50.

{

return NumArray[startIndex]; // return value is there is only one

// entry

} else if (findMin(NumArray, startIndex, endIndex - 1) < NumArray[endIndex]) {

return findMin(NumArray, startIndex, endIndex - 1);

} else {

return NumArray[endIndex];

}

}

/**

* This method is used to find the sum of negative numbers in the array

* "at"param NumArray

* "at"param startIndex

* "at"param endIndex

* "at"return

*/

public int computeNegativeSum(Integer[] NumArray, int startIndex,

int endIndex) {

if (startIndex == endIndex) {

if (NumArray[startIndex] > 0) {

return 0;

} else {

return NumArray[startIndex];

}

} else if (NumArray[endIndex] < 0) {

return computeNegativeSum(NumArray, startIndex, endIndex - 1)

+ NumArray[endIndex];

} else {

return computeNegativeSum(NumArray, startIndex, endIndex - 1); // if

}

}

/**

* This method is used to find the sum of numbers at odd indexes (1,3, 5,...),

*

* "at"param NumArray

* "at"param startIndex

* "at"param endIndex

* "at"return

*/

public int computeSumAtOdd(Integer[] NumArray, int startIndex, int endIndex) {

if (startIndex == endIndex) {

if (startIndex % 2 == 1) {

return NumArray[startIndex];

} else {

return 0;

}

} else {

if (endIndex % 2 == 1) {

return computeSumAtOdd(NumArray, startIndex, endIndex - 1)

+ NumArray[endIndex];

} else {

return computeSumAtOdd(NumArray, startIndex, endIndex - 1);

}

}

}

/**

* This method is used to find the number of even numbers within the array

*

* "at"param NumArray

* "at"param startIndex

* "at"param endIndex

* "at"return

*/

public int computeCountEven(Integer[] NumArray, int startIndex, int endIndex) {

if (startIndex == endIndex) {

if (NumArray[startIndex] % 2 == 0) {

return NumArray[startIndex];

} else {

return 0;

}

} else if (NumArray[endIndex] % 2 == 0) {

return computeCountEven(NumArray, startIndex, endIndex - 1)

+ NumArray[endIndex];

} else {

return computeCountEven(NumArray, startIndex, endIndex - 1); // if

}

}

public static void main(String args[]) {

Assignment9 assignment9 = new Assignment9();

}

}

Sample Output is :

*************************

Please enter the numbers , press 0 to stop

5

7

3

2

4

-7

-3

0

The minimum number is 3

The sum of the negative numbers is 0

The sum of the numbers at odd indexes is 9

The total count of even integers is 2

8 0
3 years ago
Al E
zzz [600]

Answer:

A. Fit test

Explanation:

i did this before, hope i helped

5 0
3 years ago
A certain computer has a 4meg address space. how many bits wide is this computer's address bus?
PIT_PIT [208]
22 bits






-----------------------------------
4 0
3 years ago
Python will ignore any line of code that begins with hashtag true or false​
fgiga [73]

Answer:

True

Explanation:

Yes

3 0
3 years ago
Read 2 more answers
How many bit strings of length 12 contain the substring 111000?
ELEN [110]

Answer:

448 strings

Explanation:

Each bit string can be filled by two ways either 0 or 1. If the bit strings of length contain the substring '111000' we therefore need a substring of length 6.

The selection of bits starts from the 1st bit to 7th bit enclosing the substring 111000 and ensuring that the length 6 are all filled. So, there will be  7 ways to contain this substring.

The total ways to contain this substring = 7*2^6 =448

Therefore 448 strings of length 12 contain the substring '111000'.

7 0
3 years ago
Other questions:
  • Binary Number Cards
    15·1 answer
  • What was named the worst game ever?
    14·2 answers
  • A "slideument" is:
    14·1 answer
  • Complete function PrintPopcornTime(), with int parameter bagOunces, and void return type. If bagOunces is less than 2, print "To
    5·1 answer
  • Give four examples of devices which are both<br>Input and Output to a Computer.​
    12·1 answer
  • Define a class named person that contains two instance variables of type string that stores the first name and last name of a pe
    14·1 answer
  • Which sorting algorithm is LEAST efficient when performed on an array in which the values are already in the desired sorted orde
    5·1 answer
  • Please name the OOP term that allows children classes to have methods with the same names as methods in their parents.
    10·1 answer
  • What is a computer ?​
    12·2 answers
  • You can click the tabs at the bottom of a workbook to switch between.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!