Question

4) Write a java program where you will use while loop, where if condition is equal...

4) Write a java program where you will use while loop, where if condition is equal to 2 (or any other choice of your number) then it will break the while condition.

Steps:

1) Declare variable int (any name) which is equal to zero

2) Declare while condition which variable int is less then equal to 10

3) Declare print out where the value of variable is the same name that you declared in step 1

4) Declare condition if where variable of step 1 is == to two then break

5) Declare increment of variable that you declared in step 1 by one

6) Show system print

5) Write a java program with scanner object to input first number and second number as variable with input statement and system out print statement.

Steps:

1) Declare scanner object

2) Ask system out print for first number and declare variable first number

3) Ask system out print for second number and declare variable second number

4) Declare first for loop where variable int i has already a value (your choice), that i is less then equal to ? and i?

5) Declare the inner for loop where variable int j has already a value (your choice), that j is less then equal to ? and j?

6) Declare the variable sum where i and j use addition (or multiplication or subtraction/ your choice)

7) Declare the if condition where sum is greater then 8 (or your choice) then break statement

8) In the end print statement where i and j are using your computation of choice and displaying the sum. Note: be careful with bracket.

6) Write a program that lets the user enter the loan amount, number of years, and interest rate and displays the amortization schedule for the loan.

Steps: 1) Create scanner

2) Prompt the user to enter loan amount and declare double variable and relate to scanner input

3) Prompt the user to enter number of years and declare integer years and relate to scanner input

4) Prompt the user to enter annual interest rate and declare double variable and relate to scanner input

5) Calculate monthly interest rate: first create a double variable called monthlyRate which is equal to annualRate divided by 1200

6) Calculate monthly payement: first create double variable called monthlyPayement which is equal to loanAmount times monthlyRate divied by (1 - 1 / Math.pow(1 + monthlyRate, years * 12));

7) Display in console monthlyPayement

8) Display in console total amount with formula inside of prompt (monthlyPayement*12) * years);

9) Create so called amortization schedule: first create double variable called balance which is equal to loanAmount, principal, interest;

10) System.out.println ("Payment# Interest Principal Balance"); for (int i = 1; i <= years * 12; i++) { interest = monthlyRate * balance; principal = monthlyPayment - interest; balance = balance - principal; System.out.printf("%-13d%-13.2f%-13.2f%.2f\n", i, interest, principal, balance); }

Homework Answers

Answer #1

Answer for Question 4:

import java.util.*;
public class Main
{
   public static void main(String[] args) {
   // declaring variable
   int var=0;
   // while condition
   while (var<=10){
   // printing variable
   System.out.println(var);
   // condition checks is var ==2
   if (var==2){
   // it breaks loop if it satisfied
   break;
   }
   // incrementing variable
   var++;
   }
}
}

Answer for question number 5

import java.util.*;
public class Main
{
   public static void main(String[] args) {
   Scanner obj = new Scanner(System.in);
   int sum=0;
   // promting user
   System.out.println("Enter first number:");
   // taking input from the user
   int first_number=obj.nextInt();
   System.out.println("Enter second number:");
   // taking input from the user
   int second_number=obj.nextInt();
   for( int i=0; i <= first_number;i++){
   for(int j=0;j<=second_number;j++){
   sum=i+j;
   if (sum>=8){
   break;
   }
  
   }
     
   }
   System.out.println("sum:"+sum);
  
}
}

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
1) Write a java programming using a while loop where you will add numbers and when...
1) Write a java programming using a while loop where you will add numbers and when you press number 0 it will add all your numbers and display the results. Use Scanner object. Steps: 1) Declare variables integer called sum which is equal to zero   2) Declare Scanner object   3) Declare while condition where is true   4) Inside of that condition prompt the user to enter the numbers   5) Declare variable integer called number and input the number statement   6)...
5) Write a java program with scanner object to input first number and second number as...
5) Write a java program with scanner object to input first number and second number as variable with input statement and system out print statement. Steps: 1) Declare scanner object 2) Ask system out print for first number and declare variable first number 3) Ask system out print for second number and declare variable second number 4) Declare first for loop where variable int i has already a value (your choice), that i is less then equal to ? and...
1) Write a java programming nested while loop where you will declare two numbers one for...
1) Write a java programming nested while loop where you will declare two numbers one for outer loop and the other one for inner while loop, and display the result. (Try using scanner) Steps: 1) Declare the variable of outer loop int and assign value of your choice 2) Declare while condition which outer variable is less the number of your choice 3) Declare variable of inner loop int and assign the value of your choice 4) Declare while condition...
2). Question with methods use scanner (Using Java): You are going to invest the amount, then...
2). Question with methods use scanner (Using Java): You are going to invest the amount, then you going to compute that amount with annual interest rate. 1) Prompt the user to enter student id, student name, student major 2) Declare variables consistent with names that you are prompting and relate them to the scanner 3) Declare the amount invested in college, prompt the user to ask for amount and declare variable and scanner to input 4) Declare the annual interest...
4) Write a Java program using Conditions: Write a program where it will ask user to...
4) Write a Java program using Conditions: Write a program where it will ask user to enter a number and after that it will give you answer how many digits that number has. Steps: 1) Create Scanner object and prompt user to enter the number and declare variable integer for input 2) Use if else condition with && condition where you will specify the digits of numbers by writing yourself the digit number that should display: Example(num<100 && num>=1), and...
4) Create the following in a Java program. Create a Scanner Prompt the user to Receive...
4) Create the following in a Java program. Create a Scanner Prompt the user to Receive the amount and declare the variable double amount for scanner Declare variable integer remaining amount which is equal to (int) (amount*100) Find the number of one dollars bt declaring the integer variable which is equal to remaining amount divided by 100 Declare: remaining amount %=100 Find the number of quarters: Declare integer variable number of quarters equal to remaining amount divided by 25 Declare:...
4.2.2 Basic while loop with user input. JAVA Write an expression that executes the loop while...
4.2.2 Basic while loop with user input. JAVA Write an expression that executes the loop while the user enters a number greater than or equal to 0. Note: These activities may test code with different test values. This activity will perform three tests, with user input of 9, 5, 2, -1, then with user input of 0, -17, then with user input of 0 1 0 -1. See "How to Use zyBooks". Also note: If the submitted code has an...
5) Create a Java program using Scanner: Write a program where you will enter the grade...
5) Create a Java program using Scanner: Write a program where you will enter the grade score for 5 classes, then it will display total points and average and it will display the grade based on percentage. Steps: 1) Declare variable integer for English, Chemistry, Java Programming, Physics and Math 2) Declare variable total and percentage 3) Create Scanner object and prompt the user to enter grades for each class and input grades after each class 4) Calculate total of...
rite a Java Program to play your version of the Texas Pick 3 Lottery. You will...
rite a Java Program to play your version of the Texas Pick 3 Lottery. You will need to include the provided code given below in your program. Task:The program will prompt for a number between 0 and 999. Your program will display the number of attempts it took for the entered number to match a randomly generated number. In the main() method, declare an int named myPick3choice. Create a prompt for myPick3choice as "Enter your Pick 3 choice:0-999". Create a...
JAVA Prompt the user for 10 numbers using a while loop. Create an int variable number....
JAVA Prompt the user for 10 numbers using a while loop. Create an int variable number. You have three additional int variables pos, neg, and zero. Your goal is to determine the number of positive, negative, and zeroes in the list of the ten numbers read in.
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT