---
tags: Cmoney_Java題目
---
Java_Cmoney_Low
===
ot0001_A+B
---

```java=
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
System.out.println(a + b);
}
}
```
ot0002_簡易四則運算
---

```java=
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
System.out.println(2 * a + 6 / b + c);
}
}
```
ot0003_直角三角形面積
---


```java=
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
float a = sc.nextFloat();
float b = sc.nextFloat();
System.out.println(a * b / 2);
}
}
```
ot0004_BMI計算
---


```java=
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
float a = sc.nextFloat();
float b = sc.nextFloat();
float c = b / (float) Math.pow((a / 100), 2);
if(c<18.5)
System.out.printf("%.1f" + " 過輕",c);
else if(c<24)
System.out.printf("%.1f" + " 正常",c);
else if(c<27)
System.out.printf("%.1f" + " 過重",c);
else if(c<30)
System.out.printf("%.1f" + " 輕度肥胖",c);
else if(c<35)
System.out.printf("%.1f" + " 中度肥胖",c);
else
System.out.printf("%.1f" + " 重度肥胖",c);
}
}
```
ot0005_三個數字取最小值
---

```java=
import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int[] a = new int[3];
for (int i = 0; i < 3; i++) {
a[i] = sc.nextInt();
}
Arrays.sort(a);
System.out.print(a[0]);
}
}
```
ot0006_計算任意數字總和
---

```java=
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int[] a = new int[sc.nextInt()];
int sum =0 ;
for (int i = 0; i < a.length; i++) {
a[i] = sc.nextInt();
sum += a[i];
}
System.out.print(sum);
}
}
```
ot0008_反轉數字
---

```java=
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String a = sc.nextLine();
char[] b = a.toCharArray();
for (int i = a.length() - 1; i > -1; i--) {
System.out.print(b[i]);
}
}
}
```
ot0009_計算平均值
---


```java=
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int sum = 0, count = 0;
while (true) {
int a = sc.nextInt();
if (a == -1)
break;
sum += a;
count++;
}
System.out.println(sum / count);
}
}
```
ot0010_最大公因數
---

```java=
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
while (b != 0) {
int tmp = a % b;
a = b;
b = tmp;
}
System.out.println(a);
}
}
```
st101_答題數判斷
---

```java=
import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = 0;
a = sc.nextInt();
if (a*60 % 100 != 0)
a = a * 60 / 100 + 1;
else
a = a * 60 / 100;
System.out.println(a);
}
}
```
st102_分數判斷
---


```java=
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = 0, score = 0;
a = sc.nextInt();
if (a <= 10)
score = a * 6;
else if (a <= 20)
score = (a - 10) * 2 + 60;
else if (a <= 40)
score = (a - 20) + 80;
else
score = 100;
System.out.println(score);
}
}
```
st103_判斷等比數列
---

```java=
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] numbers = new int[n];
for (int i = 0; i < n; i++) {
numbers[i] = sc.nextInt();
}
int r = numbers[1] / numbers[0];
for (int i = 0; i < n - 1; i++) {
if (numbers[i + 1] / numbers[i] != r) {
System.out.println("false");
break;
}
if (i == n - 2)
System.out.println("true");
}
}
}
```
st105_連續判斷質數
---


```java=
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
for (int i = 0; i < n; i++) {
System.out.println(prime(sc.nextInt()));
}
}
public static Boolean prime(int number) {
if (number == 1) {
return false;
}
for (int i = 2; i < number; i++) {
if (number % i == 0)
return false;
}
return true;
}
}
```
ft7101_健走運動
---


```java=
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
int d = sc.nextInt() * 60;
System.out.println(t / d);
}
}
```
ft7102_運動成效
---


```java=
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int bmi = sc.nextInt();
if(bmi<110)
System.out.println("非運動狀態");
else if(bmi<120)
System.out.println("輕度");
else if(bmi<140)
System.out.println("輕中度");
else if(bmi<160)
System.out.println("中度");
else
System.out.println("高強度");
}
}
```
ft7103_運動成效2
---


```java=
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int noEx = 0, ex = 0;
for (int i = 0; i < 7; i++) {
int tmp = sc.nextInt();
if (tmp == 0)
noEx++;
else
ex += tmp;
}
if (noEx == 2) {
if (ex >= 100)
System.out.println("有運動且有成效");
else
System.out.println("有運動");
} else if (noEx <= 1) {
if (ex >= 100)
System.out.println("過度運動");
else
System.out.println("有運動");
} else {
if (ex >= 100)
System.out.println("有運動");
else
System.out.println("偷懶");
}
}
}
```
ft7104_正反數列
---


```java=
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
for (int i = 0; i < n; i++) {
int m = sc.nextInt();
int[] numbers = new int[m];
for (int j = 0; j < m; j++) {
numbers[j] = sc.nextInt();
}
for (int j = 0; j < m - 1; j++) {
if (numbers[j] * numbers[j + 1] > 0) {
System.out.println("false");
break;
}
if (j == m - 2)
System.out.println("true");
}
}
}
}
```
ft7105_運動成效3
---


```java=
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int now = sc.nextInt();
int dream = sc.nextInt();
int m = 0;
while (now != dream) {
if(now>dream){
now-=4;
m++;
}
else{
now+=15;
m++;
}
}
System.out.println(m);
}
}
```
ft7201_金額紀錄
---


```java=
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int S = sc.nextInt();
int car = sc.nextInt();
System.out.println(car * 30 * 100 / S);
}
}
```
ft7202_記帳成效
---


```java=
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int LM = sc.nextInt();
int TM = sc.nextInt();
int dif = TM-LM;
if(dif<=0)
System.out.println("成效良好");
else if(dif<=999)
System.out.println("成效一般");
else
System.out.println("無效");
}
}
```
ft7203_記帳成效2
---


```java=
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int yes = sc.nextInt();
int dd = 0;
int id = 0;
for (int i = 0; i < 6; i++) {
int td = sc.nextInt();
if (td - yes >= 1000)
continue;
else if (td > yes)
id++;
else if (td < yes)
dd++;
}
if (dd > id)
System.out.println("變得節省");
else if (dd < id)
System.out.println("變得會花");
else
System.out.println("沒變");
}
}
```
ft7204_奇偶數列
---


```java=
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
for (int i = 0; i < n; i++) {
int m = sc.nextInt();
int[] numbers = new int[m];
for (int j = 0; j < m; j++) {
numbers[j] = sc.nextInt();
}
for (int j = 0; j < m - 1; j++) {
if (odd(numbers[j]) + odd(numbers[j + 1]) != 1) {
System.out.println("false");
break;
}
if (j == m - 2)
System.out.println("true");
}
}
}
public static int odd(int number) {
if (number % 2 == 0)
return 0;
else
return 1;
}
}
```
ft7205_記帳成效3
---


```java=
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int sum = 0;
int tmp = 0;
int conti = 0;
while (n != 0) {
if (n != -1) {
tmp = n;
sum += n;
conti = 0;
}
if (conti == 0 && n == -1) {
sum -= tmp;
conti++;
}
n = sc.nextInt();
}
System.out.println(sum);
}
}
```
st201_成績調整
---

```java=
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
System.out.println(n*4/10+60);
}
}
```
st202_降雨機率1
---


```java=
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
if(n<=30)
System.out.println("出門");
else if(n<=60)
System.out.println("帶傘出門");
else
System.out.println("不出門");
}
}
```
st203_降雨機率2
---


```java=
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int d = sc.nextInt();
for (int i = 0; i < d; i++) {
int n= sc.nextInt();
if (n <= 30)
System.out.println("出門");
else if (n <= 60)
System.out.println("帶傘出門");
else
System.out.println("不出門");
}
}
}
```
st204_降雨機率3
---


```java=
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int max = 0;
int n = 0;
while (true) {
n = sc.nextInt();
if (n == -1)
break;
if (n > max)
max = n;
}
if (max <= 30)
System.out.println("出門");
else if (max <= 60)
System.out.println("帶傘出門");
else
System.out.println("不出門");
}
}
```
st205_倒著數出
---

```java=
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = 0;
int count = 0;
int[] arr = new int[2];
while (true) {
n = sc.nextInt();
if (n == -1)
break;
if (count == arr.length)
arr = DA(arr);
arr[count] = n;
count++;
}
for(int i = arr.length-1;i > -1;i--)
System.out.println(arr[i]);
}
public static int[] DA(int[] arr) {
int[] newarr = new int[arr.length + 1];
for (int i = 0; i < arr.length; i++)
newarr[i] = arr[i];
return newarr;
}
}
```
ft8101_物理模擬程式
---


```java=
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int v = sc.nextInt();
int t = sc.nextInt();
System.out.println(v * t);
}
}
```
ft8102_物理模擬程式2
---


```java=
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int v, t, sum = 0;
for (int i = 0; i < n; i++) {
v = sc.nextInt();
t = sc.nextInt();
sum += v * t;
}
System.out.println(sum);
}
}
```
ft8103_骰子遊戲
---


```java=
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int[] arr = new int[3];
int max = 0;
for (int i = 0; i < 3; i++) {
arr[i] = sc.nextInt();
arr[i] += sc.nextInt();
if (arr[i] > max)
max = arr[i];
}
if (max == arr[0])
System.out.println("A");
else if (max == arr[1])
System.out.println("B");
else
System.out.println("C");
}
}
```
ft8104_海拔與氣溫
---


```java=
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
if (n == 1) {
double tem = sc.nextDouble();
int al = sc.nextInt();
System.out.printf("%.2f",tem - al / 100 * 0.6);
}
else {
double tem = sc.nextDouble();
int al = sc.nextInt();
System.out.printf("%.2f",tem - al / 100 * 0.36);
}
}
}
```