Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package encapsulation;
- import java.util.Scanner;
- public class AccountProgram {
- Scanner userIn = new Scanner(System.in);
- Account acc = new Account();
- double balance;
- double interest;
- double deposit;
- double withdraw;
- public void SetValues() {
- System.out.print("Enter balance: ");
- balance = userIn.nextInt();
- System.out.println("");
- System.out.print("Enter interest: ");
- interest = userIn.nextInt();
- acc = new Account(balance, interest);
- }
- public void choose(){
- System.out.print("Hva vil du gjøre? Se penger 'V', se rente 'I', sette inn 'D', ta ut 'W', endre rente 'C', 'E' for å avslutte");
- char answer = userIn.next().charAt(0);
- run(answer);
- }
- public void run(char a){
- switch(a){
- case 'D': System.out.print("Skriv inn ønsket innskudd: ");
- double amount = userIn.nextDouble();
- acc.deposit(amount);
- case 'W': System.out.print("Skriv inn ønsket uttak: ");
- double withdr = userIn.nextDouble();
- acc.withdraw(withdr);
- case 'V': System.out.println("Balance: " + acc.getBalance());
- case 'I': System.out.println("Interest rate: " + acc.getInterestRate());
- case 'C': System.out.print("Skriv inn ny rente: ");
- double newInterest = userIn.nextDouble();
- acc.setInterestRate(newInterest);
- case 'E': System.out.println("Avslutter");
- close();
- default: System.out.println("Du skrev inn noe feil prøv igjen(Husk capslock)");
- choose();
- }
- }
- public void close(){
- userIn.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement