-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLesson_1MyCalc.java
37 lines (29 loc) · 1.03 KB
/
Lesson_1MyCalc.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import java.util.Scanner; // импорт сканера
import java.io.*;
class MyCalc {
public static void main(String args[])
{
// Приглашение на ввод 1
System.out.print("Введите число, которое надо возвести в степень: ");
Scanner scan1 = new Scanner(System.in);
int number = scan1.nextInt();
// Приглашение на ввод 2
System.out.print("Введите степень: ");
Scanner scan2 = new Scanner(System.in);
int power = scan2.nextInt();
// Возведение в степень
System.out.println(Math.pow(number, power));
double result = Math.pow(number, power);
File file = new File ("output.txt");
try
{
PrintWriter printWriter = new PrintWriter(file);
printWriter.println (result);
printWriter.close();
}
catch (FileNotFoundException ex)
{
System.out.println(result);
}
}
}