Language/JAVA
[JAVA]자바기초/자바연산자/산술연산자예제2
영보로그
2020. 6. 23. 10:35
반응형
* 문제
사용자로부터 세 개의 정수를 입력받은 다음에 곱과 합을 순서대로 진행해서 그 결과를 출력하는 프로그램을 작성해보자. 예) 입력받은 정수가 1,2,3아러면 1*2+3의 계산결과를 출력하는 프로그램을 작성해라. |
* 소스 코드
import java.util.Scanner;
public class 문제13 {
public static void main(String[] args) {
Scanner scan=new Scanner(System.in);
System.out.println(" 세개의 정수를 입력하세요 :");
int a = scan.nextInt();
int b = scan.nextInt();
int c = scan.nextInt();
System.out.println(" 계산 결과 : "+(a*b+c));
}
}
*실행 결과
반응형