bartleby

Videos

Expert Solution & Answer
Book Icon
Chapter 4, Problem 2E

Explanation of Solution

Algorithm to develop a monthly balance sheet:

Step 1: First, get initial deposit amount from the user.

Step 2: For each month, calculate the interest amount which is done dividing the yearly percentage rate by 12.

Step 3: For each month, get the type of transaction the user wants to do.

Step 4: If the user wants to deposit, then get the deposit amount and calculate the balance amount by adding deposit amount and balance amount.

Step 5: If the user wants to withdraw amount, then get the deposit amount and calculate the balance amount by subtracting withdraw amount from balance amount.

Step 6: Print the balance amount for that month.

Step 7: Repeat the same process for each month using “for” loop.

Program:

//Import required package

import java.util.Scanner;

import java.text.DecimalFormat;

//Define the Main class

public class Main

{

    //Define main method

    public static void main(String[] args)

    {

        //Declare required variables

double balanceAmt = 0, depositAmt, withdrawAmt, interestAmt;

        double numOfMonths = 12, rate = 5;

        String transaction, t;

        //Create an object for decimal format

        DecimalFormat df = new DecimalFormat(".##");

        //Create an object for scanner class

        Scanner sc = new Scanner(System.in);

        //Get the initial deposit amount

System.out.print("Enter the initial deposit amount: ");

        balanceAmt = sc.nextDouble();

        //Print the starting balance

System.out.println("Your initial balance is: " + balanceAmt);

        //Loop from 1 through 12

        for(int i = 1; i <= numOfMonths; i++)

        {

            //Calculate interest amount

             interestAmt = ((rate/numOfMonths)*100);

             //Calculate balance amount

             balanceAmt += interestAmt;

             //Print the month number

             System.out.println("\nMonth " + i);

             //Print the intereset amount

System.out.println("\nInterest amount for month " + i + " is: " + df.format(interestAmt));

//Print the balance amount after adding interest amount

System.out.println("Balance after adding interest is: " + df.format(balanceAmt));

             //Get the character for transaction

System.out.print("\nWhat type of transaction you like to make?\nPress 'd' to deposit and 'w' to withdraw: ");

             transaction = sc.next();

             //Check if the 1st character is d

             if(transaction...

Blurred answer
Students have asked these similar questions
You have learned in class the major steps that occur when a laptop requests a webpage after connecting to a network. In this assignment, you will apply that knowledge to another scenario: opening and playing a YouTube video that resides in Google's data-center infrastructure. Explain, in as much detail as you can, all the steps involved from your device's initial connection to the home/university network, to DNS resolution, routing across multiple networks, reaching Google's servers, and finally receiving the video data. To support your explanation, use tools such as ipconfig, nslookup, and tracert on your own computer, as well as any online IP-lookup tools of your choice. For each stage, include relevant information such as IP addresses, MAC addresses, router hops, and any other details you can gather. You are not expected to find every piece of information, but be as comprehensive as possible based on what you have learned in class, and justify your reasoning with screenshots from…
I need help with this question, please don,t use AI or chatgpt.
NO USE OF AI PLEASE

Chapter 4 Solutions

Java: An Introduction To Problem Solving And Programming Plus Mylab Programming With Pearson Etext -- Access Card Package (8th Edition)

Additional Engineering Textbook Solutions

Find more solutions based on key concepts
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
Systems Architecture
Computer Science
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Cengage Learning
Java random numbers; Author: Bro code;https://www.youtube.com/watch?v=VMZLPl16P5c;License: Standard YouTube License, CC-BY