public class Eksamensøving2 {
private static String Marcus;
private static String Peter;
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Konto kontoer [] = new Konto[2];
kontoer [0] = new Konto(100,"Marcus");
kontoer [1] = new Konto(200,"Peter");
System.out.println("Saldo er: " + kontoer[1].getSaldo()+"kr på kontoen til " + kontoer[0].getEier());
Konto minKonto = new Konto();
minKonto.SettInnPenger();
}
}
This is the main class
public class Konto {
double saldo;
String eier;
private Scanner input;
public Konto (double innsaldo, String inneier)
{
input = new Scanner(System.in);
saldo = innsaldo;
eier = inneier;
}
public double getSaldo () {
return saldo;
}
public String getEier () {
return eier;
}
public void SettInnPenger (){
int settInn;
String kontoSettInn;
System.out.println("Skriv in navnet på kontoen;");
kontoSettInn = input.nextLine();
if (kontoSettInn == eier) {
System.out.println("Skriv in beløpet du vil sette inn:");
settInn = input.nextInt();
saldo = saldo + settInn;
System.out.println("beløpet på kontoen er:"+ saldo);
}
else
System.out.println("denne kontoen finnes ikke.");
}
}
I'm having problems with creating and assigning a object to the konto class. minKonto should call the settInnPenger method, but for some reason it gets an error. Will appriciate all the help i get.