Create a class BankAccount with 2 variables, a int balance, and a string name. Then create an instance of the BankAccount Class, change its name and balance, and print its name and balance.

Answers

Answer 1

Answer:

Follows are the code to the given question:

class BankAccount //defining a class BankAccount

{

 int balance;//defining integer variable balance  

 String name;//defining String variable name

 BankAccount()//defining default constructor

 {

 }

  BankAccount(int balance, String name)//defining parameterized constructor that accepts two parameters  

  {

     this.balance = balance;//use this to hold parameter value

     this.name = name;//use this to hold parameter value

  }

}

public class Main//defining Main class

{

 public static void main(String[] asr)//main method  

 {

  BankAccount obv = new BankAccount(1969, "Mustang");//creating class object and pass value in parameter

   System.out.println("Your name is: " + obv.name + " and " +"Your balance is: "+ obv.balance);//print value with message

 }

}

Output:

Your name is: Mustang and Your balance is: 1969

Explanation:

In this code a class "BankAccount" is declared, that  defines the two variable "name and balance" as a integer and string, and in the next step a parameterized constructor is declared, that uses this keyword to hold value.

In the main class the main method is declared and inside the method class object is created that accepts parameter value and use the print method to print its value.


Related Questions

ERIC'S Company sells cement at 30.0 Ghana Cedis per bag. The company

however gives discount of 15% for customers that buy 100 or more bags, and 0% for

customers that buy less than 100 bags.
Write a pseudo code and present a flowchart that

will display the discount percentage when the quantity of bags purchased is entered.​

Answers

Answer:

The pseudocode is as follows:

Input Quantity

Discount = 0%

If Quantity >= 100:

    Discount = 15%

Print Discount

See attachment for flowchart

Explanation:

This line gets the quantity from the user

Input Quantity

This line initializes the discount to 0%

Discount = 0%

This checks if quantity is more than or equal to 100

If Quantity >= 100:

If yes, discount is set to 15%

    Discount = 15%

This prints the discount percentage

Print Discount

See attachment for flowchart

BitTorrent, a P2P protocol for file distribution, depends on a centralized resource allocation mechanism through which peers are able to maximize their download rates.
True or False?

Answers

Answer:

yes. it is true. mark as brainlest

Other Questions
relate diffusion and equilibruim Metals are amazing, and they are all around us. You can probably easily identify them by their shiny surfaces and tinny sound when you tap them.a. Trueb. False What is the difference between an independent variable and a dependent variable in statistics? HELP ASAPPPPP PLS ASAPPP NEED HELP ASAP!! ill mark brainliest 1 point2. Te cepillas los dientes en la maana? Do you brush your teeth in themorning?1.No, no se los cepillan2.No, no me los cepillo3.No, no te los cepillas4.No, no nos los cepillamosO 5.No, no se los cepilla 2.What type of a quadrilateral is defined by the vertices (-5, 7), (2,6), (5, -3), (-4, 0)?a Kiteb RectangleC Rhombusd Parallelogram It is the amount of money that a seller sets for the item or product for sale? Solve for r in the expression 3 (2 - 5) = 12. 10. Logan places a mirror on the floor 220 cm from the base of a wall. He holds a flashlight 130 cm above the ground and shines the beam onto the mirror. How far must Logan stand back from the mirror so that the height at which the light shines on the wall is 100 cm greater than the height at which Logan holds the flashlight? 20 x(-1) = *Your answer-20 PLS HELPPPPPPPPPPPPPP IM CRYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY Which is correct ? Im really confused Bentley invested $430 in an account paying an interest rate of 2.5% compounded continuously. Assuming no deposits or withdrawals are made, how long would it take, to the nearest year, for the value of the account to reach $510? 2 of 5Work out the area of the parallelogram.9m6m11mThe diagram is not drawn to scale.m2 i need help pleaseeeeeee Plz help fast will mark brainliest Briefly describe the relationship between self and society? Where did the Inca live? What is the distance between the points (13 , -19) and (-12 , -19) in the coordinate plane?