

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
Various java programming examples. The first example demonstrates the use of if else statements with user input. The second example illustrates an account class with getter and setter methods. The third example shows a car class with properties and methods. The fourth example presents another account class with a transaction class.
What you will learn
Typology: Exercises
1 / 3
This page cannot be seen from the preview
Don't miss anything!
public class Accounts { private double accountA ; private double accountB; public double getAccountA() { return accountA; } public void setAccountA( double accountA) { this .accountA = accountA; } public double getAccountB() { return accountB; } public void setAccountB( double accountB) { this .accountB = accountB; } }
public class MainClass { public static void main (String args[]){ Transaction Balance = new Transaction (); Transaction Deposit = new Transaction (); Accounts accountA = new Accounts (); Accounts accountB = new Accounts (); accountA.equals(Balance); accountB.equals(Deposit); System. out .println( "accountA = " + Balance.getBalance()); System. out .println("accountB = " + Deposit.getDeposit()); } }
public class Transaction { private double Balance = 500; private double Deposit = 400; private double Amount = 300; Accounts accountA = new Accounts (); Accounts accountB = new Accounts (); public double getDeposit() { return Deposit + Amount ; } public void setDeposit( double deposit) { Deposit = deposit; } public double getAmount() { return Amount; } public void setAmount( double amount) { Amount = amount; } public double getBalance() { return Balance - Amount; } public void setBalance() { this .Balance = Balance ; } }
public class car { String Color; String Model; double Engine; int Doors;