1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
import java.io.*;
class Rei5_3{
public static void main(String[] args)
throws IOException{
BufferedReader br = new
BufferedReader(
new InputStreamReader(System.in));
System.out.print("1つめの値を入力:");
String str1 = br.readLine();
System.out.print("2つめの値を入力:");
String str2 = br.readLine();
int num1 = Integer.parseInt(str1);
int num2 = Integer.parseInt(str2);
num1 = num1 + num2;
System.out.println("2つの値の和:" + num1);
}
}
|
using System;
class Rei5_3{
static void Main(){
Console.Write("1つめの値を入力:");
string str1 = Console.ReadLine();
Console.Write("2つめの値を入力:");
string str2 = Console.ReadLine();
int num1 = Convert.ToInt32(str1);
int num2 = Convert.ToInt32(str2);
num1 = num1 + num2;
Console.WriteLine("2つの値の和:" + num1);
}
}
|