09.20 과일입력, 숫자입력, 문자열에 따옴표입력
C#/실습 2019. 9. 20. 10:21예제:
코드:
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
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace _09._20
{
class Program
{
static void Main(string[] args)
{
Console.Write("당신이 좋아하는 과일의 이름은 무엇입니까? ");
string fruit = Console.ReadLine();
Console.WriteLine($"오! 당신은 {fruit}를 좋아하는군요!");
Console.WriteLine();
Console.WriteLine();
Console.WriteLine("*** 0보다 크고 100보다 작은 숫자 두개를 입력하고 출력 하기***");
Console.Write("첫번째 숫자를 입력 해 주세요: ");
string strnum1 = Console.ReadLine();
Console.Write("두번째 숫자를 입력 해 주세요: ");
string strnum2 = Console.ReadLine();
Console.WriteLine($"당신이 입력한 숫자는 {strnum1}, {strnum2}입니다.");
int num1 = Convert.ToInt32(strnum1);
int num2 = Convert.ToInt32(strnum2);
Console.WriteLine($"당신이 입력한 숫자의 합은 {num1 + num2}입니다.");
}
}
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
|
'C# > 실습' 카테고리의 다른 글
09.23 상점 구매하기 및 판매하기 (0) | 2019.09.23 |
---|---|
09.20 줄넘기 (0) | 2019.09.20 |
09.20 for문을 이용한 던전게임 (0) | 2019.09.20 |
구구단 (convert를 이용한 string형식을 int 형식으로 변환, tryparse를 이용한 문자와 숫자 구분) (0) | 2019.09.19 |
2019/09/19 for 루프 (1) | 2019.09.19 |