Wenn ich den Quelltext ausführe und für eingabe = 324 eingebe, wird komischerweise
Wie viel Cent haben Sie?
324
Das sind 3 Dollar und 68 Cent
oder
Wie viel Cent haben Sie?
204
Das sind 2 Dollar und 68 Cent
angezeigt
Quelltext:
import java.util.Scanner;
import java.io.*;
class Dollar
{
public static void main(String[] args) throws IOException
{
long cent, dollar, rest;
System.out.println("Wie viel Cent haben Sie?");
Scanner eingabe = new Scanner(System.in);
String inData = eingabe.next();
cent = Integer.parseInt( inData );
dollar = cent / 100;
rest = cent & 100;
System.out.println("Das sind " +dollar+ " Dollar und " +rest+ " Cent");
}
}
Kann mir jemand sagen, warum das so ist?
Danke schonmal im vorraus :wink:
Wie viel Cent haben Sie?
324
Das sind 3 Dollar und 68 Cent
oder
Wie viel Cent haben Sie?
204
Das sind 2 Dollar und 68 Cent
angezeigt
Quelltext:
import java.util.Scanner;
import java.io.*;
class Dollar
{
public static void main(String[] args) throws IOException
{
long cent, dollar, rest;
System.out.println("Wie viel Cent haben Sie?");
Scanner eingabe = new Scanner(System.in);
String inData = eingabe.next();
cent = Integer.parseInt( inData );
dollar = cent / 100;
rest = cent & 100;
System.out.println("Das sind " +dollar+ " Dollar und " +rest+ " Cent");
}
}
Kann mir jemand sagen, warum das so ist?
Danke schonmal im vorraus :wink: