Java:
import inout.Console;
class fu
{
public static void main (String args[])
{
int tarifzone;
double frachtkostenanteil = 0.0;
boolean ok = true;
System.out.println("Geben Sie bit die Traifzone ein");
tarifzone = Console.readInt();
switch (tarifzone)
{
case 1: frachtkostenanteil =15.0; break;
case 2: frachtkostenanteil = 25.5; break;
case 3: frachtkostenanteil = 35.5; break;
case 4: frachtkostenanteil = 40.0; break;
default : ok = false;
}
if (ok)
System.out.println("Frachkostenanteil: "+frachtkostenanteil);
else
System.out.println("Keine gültige Tarifzone: "+tarifzone);
}
}
Wieso lässt sich dieser Code nicht kompilieren?? Es wird immer folgender Text angezeigt:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
tarifzone cannot be resolved to a variable
The method ConsolereadInt() is undefined for the type fu
tarifzone cannot be resolved to a variable
tarifzone cannot be resolved to a variable
at fu.main(fu.java:11)
Das package dazu hab ich im selben Ordner abgespeichert, aber trotzdem lässt es sich nicht kompilieren:
Hier ist das Package:
Java:
package inout;
import java.util.*;
import java.util.regex.*;
import java.text.*;
public class inout
{
private static Scanner sc;
private Console()
{
}
public static String readString()
throws NoSuchElementException, IllegalStateException
{
Scanner sc = new Scanner(System.in);
return sc.nextLine();
}
public static char[] readCharArray()
throws NoSuchElementException, IllegalStateException
{
sc = new Scanner(System.in);
String text = sc.nextLine();
return text.toCharArray();
}
public static boolean readBoolean() throws
InputMismatchException, NoSuchElementException,
IllegalStateException
{
sc = new Scanner(System.in);
return sc.nextBoolean();
}
public static int readInt() throws
InputMismatchException, NoSuchElementException,
IllegalStateException
{
return new Scanner(System.in).nextInt();
}
public static long readLong() throws
InputMismatchException, NoSuchElementException,
IllegalStateException
public static char[] readCharArray()
throws NoSuchElementException, IllegalStateException
{
sc = new Scanner(System.in);
String text = sc.nextLine();
return text.toCharArray();
}
public static boolean readBoolean() throws
InputMismatchException, NoSuchElementException,
IllegalStateException
{
sc = new Scanner(System.in);
return sc.nextBoolean();
}
public static int readInt() throws
InputMismatchException, NoSuchElementException,
IllegalStateException
{
return new Scanner(System.in).nextInt();
}
public static long readLong() throws
InputMismatchException, NoSuchElementException,
IllegalStateException
IllegalStateException
{
Locale.setDefault(Locale.ENGLISH);
return new Scanner(System.in).nextDouble();
}
public static double readDoubleComma() throws
InputMismatchException, NoSuchElementException,
IllegalStateException
{
Locale.setDefault(Locale.GERMAN);
return new Scanner(System.in).nextDouble();
}
public static char readChar() throws
NoSuchElementException,IllegalStateException
{
String s = new Scanner(System.in).next();
return s.charAt(0);
}
}
Vielen Dank für eure Hilfe, hab jetzt an dem Zeug hier schon 5 h oder so rumgebastelt