標題:
請各位務必將以下題目練熟!
[打印本頁]
作者:
周政輝
時間:
2017-7-1 11:54
標題:
請各位務必將以下題目練熟!
我挑出了一些TQC題目當中比較難或是需要注意的部分
請各位回家有空就可以多練習這些題,讓各位可以拿到證照
7/22,7/29這兩周我們也會重複把以下題目全部在做過一遍
所以請各位務必把題目弄熟
103
205
207
303
304
307
403
404
405
407
410
503
505
506
507
508
509
510
作者:
張健勳
時間:
2017-7-3 22:33
本帖最後由 張健勳 於 2017-7-8 10:03 編輯
TQC+ 103
import java.util.Scanner;
public class JPD01 {
static Scanner scanner = new Scanner(System.in);
public static void main(String[] args)
{
System.out.println("Please input: ");
float n1 = scanner.nextInt();
float n2 = scanner.nextInt();
float n3 = scanner.nextInt();
float total = (n1+n2+n3);
float avg = total/3;
System.out.println(avg);
}
}
複製代碼
TQC+ 205
import java.util.*;
public class JPD02 {
static Scanner input = new Scanner(System.in);
public static void main(String[] args) {
test();
test();
test();
test();
}
static void test() {
System.out.println("Enter an interger: ");
int n = input.nextInt();
if ( n%2==0 || n%3 ==0 || n%6 ==0 )
{
System.out.println(n+"是2,3,6的倍數");
}else if ( n%2==0 ){
System.out.println(n+"是2的倍數");
}else if ( n%3==0 ){
System.out.println(n+"是3的倍數");
}else if ( n%6==0 ){
System.out.println(n+"是6的倍數");
}else{
System.out.println(n+"不是2,3,6的倍數");
}
}
}
複製代碼
TQC+ 207
import java.util.*;
public class JPA02 {
static Scanner keyboard = new Scanner(System.in);
public static void main(String[] args) {
test();
test();
test();
test();
}
static void test() {
System.out.println("請輸入三個數字 : ");
int x = keyboard.nextInt();
int y = keyboard.nextInt();
int z = keyboard.nextInt();
if(x+y>z && x+z>y && y+z>x)
{
if(x*x + y*y == z*z)
System.out.println("直角三角形");
else if(x*x + y*y < z*z)
System.out.println("鈍角三角形");
else if(x*x + y*y > z*z)
System.out.println("銳角三角形");
}
else
{
System.out.println("不可以構成三角形");
}
}
}
複製代碼
TQC+ 303
public class JPA03{
public static void main(String argv[]) {
int i, num, sum = 0;
System.out.printf("1~1000中的完美數有: ");
for (i=1;i<=1000;i++){
sum=0;
for (num=1;num<i;num++) {
if (i%num==0)sum+=num;
}
if (i==sum) {
System.out.printf("%d ",num);
}
}
System.out.printf("\n");
}
}
複製代碼
TQC+ 304
import java.util.Scanner;
public class JPA03 {
public static void main(String[] args) {
int total = 0;
int s = 0;
int count = 0;
double average;
Scanner scanner = new Scanner(System.in);
while(true){
System.out.print("Please enter meal dollars or enter -1 to stop: ");
s = scanner.nextInt();
if (s==-1){
break;
}else{
total+=s;
count++;
}
}
average = (double)total/count;
System.out.println("餐點總費用:"+total);
System.out.printf(" %d 道餐點平均費用為: %.2f %n",count,average);
}
}
複製代碼
TQC+ 307
import java.io.*;
import java.util.Scanner;
public class JPA03 {
public static void main (String argv[]) throws IOException {
Scanner scanner = new Scanner(System.in);
int num1, num2;
System.out.println("Input:");
num1 = scanner.nextInt();
while (num1!=999) {
num2=scanner.nextInt();
System.out.println(gcd(num1,num2));
System.out.println("Input:");
num1=scanner.nextInt();
}
}
static int gcd (int m, int n) {
int result;
while (m%n!=0){
result = n;
n = m%n;
m = result;
}
return n;
}
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2