본문 바로가기

문제 풀이11

명품 JAVA 에센셜 3장 실습 문제 풀이 1. 영문 소문자를 하나 입력받고 그 문자보다 알파벳 순위가 낮은 모든 문자를 출력하는 프로그램을 작성하라. public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("영문 소문자 하나를 입력하세요>>"); String aplha = sc.next(); sc.close(); StringBuilder sb = new StringBuilder(); for(int i = 'a'; i < aplha.toCharArray()[0]; i++){ sb.append((char)i); if(i != (aplha.toCharArray()[0]-1)){ sb.append(", "); } } System.out.. 2023. 11. 28.
명품 JAVA 에센셜 2장 실습 문제 풀이 1. 두 정수를 입력받아 합을 구하여 출력하는 프로그램을 작성하라. public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a, b; a = sc.nextInt(); b = sc.nextInt(); System.out.println(a + " + " + b + " = " + (a+b)); sc.close(); } Scanner 클래스를 이용할 수 있는지에 대해 알아보기 위한 문제였습니다. 먼저 Scanner 클래스의 객체 sc를 생성해 줍니다.그 뒤에 nextInt()를 이용하여 정수를 입력받은 뒤 형식에 맞게 출력해 주면 됩니다. 2. 2차원 평면에서 하나의 직사각형은 두 점으로 표현된다. (50,50)과 (10.. 2023. 11. 28.
명품 JAVA 에센셜 1장 실습 문제 풀이 1. Welcome!!을 출력하는 자바 프로그램을 작성하라. public static void main(String[] args) { System.out.print("Welcome!!"); } 2. Sorry~~를 출력하는 자바 프로그램을 작성하라. public static void main(String[] args) { System.out.print("Sorry~~"); } 3. "1 2 3 4 5 6 7 8 9"를 출력하는 자바 프로그램을 작성하라. public static void main(String[] args) { System.out.print("1 2 3 4 5 6 7 8 9"); } Open Challenge문제. 실행결과는 다음과 같다. 지시대로 자바 응용프로그램을 작성하라. public.. 2023. 10. 31.
기본 개념과 핵심 원리로 배우는 C++ 프로그래밍 9장 프로그래밍 문제 1.다음 로봇 명세를 보고 프로그램을 작성하시오. 이름 신장(m) 무게(T) 마력 태권브이 18 80 3000 마징가 17 70 2500 메칸더브이 20 90 3500 그랜다이져 22 100 5000 (1) 로봇을 나타내는 클래스 CRobot을 설계하시오. 명세를 입력할 수 있는 멤버 함수 Set과 명세를 출력하는 멤버 함수 Print가 있다. (2)클래스 CRobot을 이용하여 모든 로봇의 명세를 출력하는 프로그램을 작성하시오. #include #include using namespace std; int cnt = 0; class CRobot{ public: int m_height[4],m_weight[4],m_power[4]; void set(int x, int y, int z){ m_height[c.. 2023. 10. 31.