- package javagently;
- import java.io.*;
- public class LasIn{
- private static BufferedReader läsin=
- new BufferedReader(
- new InputStreamReader(System.in));
- public static int läsHeltal(String p){
- try{
- System.out.print(p);
- String indata=läsin.readLine();
- int k=Integer.parseInt(indata);
- return k;
- }
- catch(Exception e){
- throw new RuntimeException(
- "läsHeltal:ej ett heltal");
- }
- }
- public static double läsFlyttal(String p){
- try{
- System.out.print(p);
- String indata=läsin.readLine();
- double k=Double.valueOf(indata).doubleValue();
- return k;
- }
- catch(Exception e){
- throw new RuntimeException(
- "läsFlyttal:ej ett flyttal");
- }
- }
- public static String läsSträng(String p){
- try{
- System.out.print(p);
- String indata=läsin.readLine();
- return indata;
- }
- catch(Exception e){
- throw new RuntimeException(
- "läsSträng:ej en sträng");
- }
- }
- }