월을 입력받아 분기를 출력하시오. 1~3월은(1분기), 4~6월은(2분기),7~9월은(3분기), 10~12월은(4분기)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp3
{
class Program
{
static void Main(string[] args)
{
Console.Write("월을 입력해 주세요: ");
int month = int.Parse(Console.ReadLine());
switch(month)
{
case 1:
case 2:
case 3:
Console.WriteLine("1분기 입니다");
break;
case 4:
case 5:
case 6:
Console.WriteLine("2분기 입니다");
break;
case 7:
case 8:
case 9:
Console.WriteLine("1분기 입니다");
break;
case 10:
case 11:
case 12:
Console.WriteLine("4분기 입니다");
break;
}
}
}
}
switch case 문을 사용하여 입력된 점수를 A+,A-,B+,B0...F로 구분하라
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp3
{
class Program
{
static void Main(string[] args)
{
Console.Write("점수를 입력해 주세요: ");
int score = int.Parse(Console.ReadLine());
// string str = score.ToString();
int g = score / 10;
switch (score % 10)
{
case 9:
case 8:
case 7:
case 6:
case 5:
Console.WriteLine($"{g}+");
break;
case 4:
case 3:
case 2:
case 1:
Console.WriteLine($"{g}0");
break;
}
}
}
}
두 개의 정수와 연산자("더하기","빼기","나누기","곱하기")를 입력받아 계산하는 프로그램을 작성하시오.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp5
{
class Program
{
static void Main(string[] args)
{
Console.Write("숫자1을 입력해 주세요: ");
int num1 = int.Parse(Console.ReadLine());
Console.Write("숫자2를 입력해 주세요: ");
int num2 = int.Parse(Console.ReadLine());
Console.Write("연산자를 입력해 주세요: ");
string input = Console.ReadLine();
switch (input)
{
case "더하기":
Console.WriteLine($"숫자1 더하기 숫자2는 {num1 + num2}입니다.");
break;
case "빼기":
Console.WriteLine($"숫자1 빼기 숫자2는 {num1 - num2}입니다.");
break;
case "곱하기":
Console.WriteLine($"숫자1 곱하기 숫자2는 {num1 * num2}입니다.");
break;
case "나누기":
Console.WriteLine($"숫자1 나누기 숫자2는 {num1 / num2}입니다.");
break;
}
}
}
}
'Programming > C#' 카테고리의 다른 글
C# 입력된 수의 평균 구하기 (0) | 2021.04.27 |
---|---|
C# 1부터 10사이의 짝수의 합 홀수의 곱 (0) | 2021.04.27 |
C# 놀이동산 실습 (0) | 2021.04.27 |
C# 윤년 (0) | 2021.04.26 |
C# 섭씨 화씨 (0) | 2021.04.26 |
댓글