K
K
KreMbI42015-01-21 14:54:20
Java
KreMbI4, 2015-01-21 14:54:20

Method repetition in Java?

There is a working program.
packagetest;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/**
* Created by
*/
public class otchet {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
double a = Integer.parseInt(reader.readLine());
double c = ((a / 87)*100);
double d = ((c/100)*13);
double e = (cd);
System.out.println(c + " Salary" );
System.out.println(d + " 13 percent");
System.out.println(e + " Verification");
}
}
Enter a number and get an answer.
What needs to be added so that after the output, the program starts again? Those. to enter a new number (the old one should remain).
p.s. I'm new to Java, don't throw stones.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
afna, 2015-01-21
@KreMbI4

В дополнение к ответу Rodgenk:

public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String line = reader.readLine();
        while (!"exit".equals(line)) {
            double a = Integer.parseInt(line);
            double c = ((a / 87) * 100);
            double d = ((c / 100) * 13);
            double e = (c - d);
            System.out.println(c + " Оклад");
            System.out.println(d + " 13 процентов");
            System.out.println(e + " Сверка");
            reader = new BufferedReader(new InputStreamReader(System.in));
            line = reader.readLine();
        }
    }

R
Rodgenk, 2015-01-21
@Rodgenk

Не нужно перезапускать программу, просто отправьте всю логику в бесконечный цикл. Выход из программы скажем по команде exit. Если старые числа нужно хранить внутри программы, то коллекции в помощь.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question