1. 돈의 액수를 입금하세요
입금한 돈을 오만원권, 만원권, 오천원권, 천원권, 500원동전, 100원동전, 50원동전, 10원동전, 1원동전 각 몇개로 변환되는지 출력하세요
출력 개수는 단위가 큰 것 순서로 계산합니다
예를 들어 78670원이면 <오만원 1매, 만원 2매, 오천원 1매, 천원 3매, 500원 1개, 100원 1개, 50원 1개, 10원 2개> 입니다.
2. 369게임을 작성합니다.
1~99까지의 정수를 입력받고
3,6,9중 하나가 있으면 "박수짝"을 출력하고
2개가 있으면 "박수짝짝"을 출력하세요
예를 들어 13은 "박수짝"
36인 경우는 "박수짝짝"을 출력하면 됩니다.
3. AB + BA = 99 를 만족하는 모든 A와 B의 조합을 구하는 프로그램을 작성하세요.
4. 다음과 같이 출력하세요.
*
***
*****
*******
*********
1. while문을 이용해서 1부터 10까지 중에 짝수만 출력하세요
while문내에 조건문을 넣어주면 됨
2. 1000이하의 자연수 중에서 2의 배수이면서 7의 배수인 숫자를 출력하고,
그 출력된 숫자들의 합을 구하는 프로그램을 작성하세요
3. 구구단을 이렇게 출력하세요
2x1=2 3x1=3...9x1=9
2x2=4
...
2x9=18........9x9=81
4. 가위, 바위, 보 게임을 만드세요.
com에 0~2까지의 랜덤값을 발생시키고
(0:가위, 1:바위, 2:보)
사용자가 가위, 바위, 보를 입력하여
com과의 승무패를 출력하세요.
(예시) com = 2, 사용자가 바위를 입력하면 => 졌습니다.
com=1, 사용자가 바위를 입력하면 => 비겼습니다.
com=0, 사용자가 바위를 입력하면 => 이겼습니다.
3 16
배열에서 최대값 찾는법
1. 20개 배열을 선언하세요
20개의 값을 난수를 이용해서 0 ~ 100까지의 값으로 채워넣고
먼저 인덱스의 홀수번째는 앞에서부터 출력하고
짝수번째는 뒤에서부터 출력하세요
2. 클래스 PhoneInfo
String[] name = new String[100];
String[] phoneNum = new String[100];
int i = 0;
public void insertPhoneInfo(String name, String number) {
//이름과 번호를 배열에 저장 이거좀어려움
}
//모든 PhoneInfo 출력
public void printAllPhoneInfo() {
}
//번호에 해당하는 이름과 번호 출력
public void printPhoneInfo(int index) {
}
import java.util.Arrays;
import java.util.Scanner;
public class re1 {
public static void main(String[] args) {
int count=0;
Scanner sc = new Scanner(System.in);
String h = sc.next();
String[] k = h.split("");
System.out.println(Arrays.toString(k));
for(int i=0;i<k.length;i++){
if(k[i].contains("3")||k[i].contains("6")||k[i].contains("9")){
count++;
}
}
if(count>0){
System.out.print("박수");
for(int i=0;i<count;i++){
System.out.print("짝");
}
}
}
}
public class re1 {
public static void main(String[] args) {
for (int a = 0; a < 10; a++) {
for (int b = 0; b < 10; b++) {
if ((10 * a) + b + (b * 10) + a == 99) {
System.out.println(a + " " + b);
}
}
}
}}
public class re1 {
public static void main(String[] args) {
for(int i=0;i<10;i++){
for(int k=10;k>i;k--){
System.out.print(" ");
}
for(int j=0;i>j;j++){
System.out.print(" *");
}
System.out.println();
}
}
}
public class re1 {
public static void main(String[] args) {
int i=1;
while(i<=10){
if(i%2==0){
System.out.println(i);}
i++;
}
}
}
public class re1 {
public static void main(String[] args) {
int sum=0;
for(int i=1;i<=1000;i++){
if(i%2==0&&i%7==0){
System.out.println(i);
sum+=i;
}
}
System.out.println(sum);
}
}
import java.util.Scanner;
public class re1 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// 0 가위 1 바위 2 보
while(true) {
int a = sc.nextInt();
int b = (int) (Math.random() * 3);
System.out.println(b);
if (a == b) {
System.out.println("비겼다.");
} else if ((a == 0 && b == 2) || (a == 1 && b == 0) || (a == 2 && b == 1)) {
System.out.println("이겼다.");
} else {
System.out.println("졌다.");
}
}
}
}
import java.util.Arrays;
public class re1 {
public static void main(String[] args) {
int[] a = new int[10];
for(int i=0;i<10;i++){
a[i] =(int) (Math.random()*100);
}
System.out.println(Arrays.toString(a));
for(int i=0;i<a.length;i++){
if(a[i]%2==0){
System.out.print(a[i] + " ");
}
}
for(int i=a.length-1;i>=0;i--){
if(a[i]%2==1){
System.out.print(a[i] + " ");
}
}
}
}
public class re1 {
public static void main(String[] args) {
int[] z = {26,4,8,39,3,2,93};
int min = 100;
for(int i=0;i<z.length;i++){
if(z[i]<min){
min = z[i];
}
}
System.out.println(min);
}
}
import java.util.Scanner;
public class re1 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
phoneinfo p = new phoneinfo();
while(true){
System.out.println("고르시오\n1.저장 2.출력 3. 인덱스출력");
int a = sc.nextInt();
if(a==1){
System.out.println("저장하시오");
String z = sc.next();
String b = sc.next();
p.insertPhoneInfo(z,b);
}
if(a==2){
p.printAllPhoneInfo();
}
if(a==3){
System.out.println("인덱스써");
int b = sc.nextInt();
p.printPhoneInfo(b);
}
}
}
}
class phoneinfo{
String[]name = new String[10];
String[]number = new String[10];
int index=0;
public void insertPhoneInfo(String name, String number) {
this.name[index] = name;
this.number[index] = number;
index++;
//이름과 번호를 배열에 저장
}
//모든 PhoneInfo 출력
public void printAllPhoneInfo() {
for(int i=0;i<name.length;i++){
System.out.println(name[i] + " " + number[i]);
}
}
//번호에 해당하는 이름과 번호 출력
public void printPhoneInfo(int index) {
System.out.println(name[index] + " " + number[ index]);
}
}
import java.util.ArrayList;
import java.util.Scanner;
public class re1 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
phoneinfo p = new phoneinfo();
while(true){
System.out.println("고르시오\n1.저장 2.출력 3. 인덱스출력");
int a = sc.nextInt();
if(a==1){
System.out.println("저장하시오");
String z = sc.next();
String b = sc.next();
p.insertPhoneInfo(z,b);
}
if(a==2){
p.printAllPhoneInfo();
}
if(a==3){
System.out.println("인덱스써");
int b = sc.nextInt();
p.printPhoneInfo(b);
}
}
}
}
class phoneinfo{
ArrayList<String> name= new ArrayList<>();
ArrayList<String> number= new ArrayList<>();
int index=0;
public void insertPhoneInfo(String name, String number) {
this.name.add(name);
this.number.add(number);
index++;
//이름과 번호를 배열에 저장
}
//모든 PhoneInfo 출력
public void printAllPhoneInfo() {
for(int i=0;i<name.size();i++){
System.out.println(name.get(i) + " " + number.get(i));
}
}
//번호에 해당하는 이름과 번호 출력
public void printPhoneInfo(int to) {
System.out.println(name.get(to) + " " + number.get(to));
}
}
[자바] 문제모음3 (3) | 2023.04.14 |
---|---|
[자바]문제모음2 (0) | 2023.04.14 |
[람다] 문자열 두개 받아서 비교하는거 (0) | 2023.04.04 |
[스트림] 꼭 외우기. 배열에서 가장 긴 문자를 리턴 (0) | 2023.03.31 |
소수찾기 알고리즘 (0) | 2023.03.30 |
댓글 영역