Lab3-BrainAge
5530216021 นายธนบดี บุญสงเคราะห์ (COM22000) (11/28/2012 (10:29:23 AM))
MiniQuiz + TestScript |
JLab>java Selftest
JLab> testSignFinder : ok ok ok ok ok ok ok ok ok ok (5.0/5.0)
JLab> testTimeLapse : ok ok ok ok ok ok ok ok ok ok (5.0/5.0)
JLab> : -----------------------------
JLab> : ?????? 10.0 ????? (???? 10.0)
JLab> : -----------------------------
JLab> :<POINT>10.0</POINT> (<TOTAL>10.0</TOTAL> )
JLab>
ได้ 10 คะแนน |
Source Code |
import java.util.Scanner;
public class TimeLapse {
public static void main(String[] args) {
// การสร้าง Scanner ข้างล่างนี้ทำให้ผู้ใช้สามารถป้อนจำนวนแต่ละตัว คั่นด้วย , ได้
Scanner kb = new Scanner(System.in).useDelimiter("\\s*[,\\s]\\s*");
System.out.print("เวลาเริ่มต้น = ");
int h1 = kb.nextInt();
int m1 = kb.nextInt();
System.out.print("เวลาสิ้นสุด = ");
int h2 = kb.nextInt();
int m2 = kb.nextInt();
int dh = 0;
int dm = 0;
int iMin1 = 0;
int iMin2 = 0;
int iSum = 0;
if (h2 < h1)
{
h2=h2+12;
}
iMin1 = h1 * 60 + m1;
iMin2 = h2 * 60 + m2;
if(iMin2 - iMin1>0)
{
iSum = iMin2 - iMin1;
}
else if (iMin1 - iMin2 < 0)
{
iSum = iMin1 - iMin2;
}
dh = iSum / 60;
dm=iSum%60;
System.out.println(dh + ":" + dm);
}
}
import java.util.Scanner;
public class SignFinder {
public static void main(String[] args) {
// การสร้าง Scanner ข้างล่างนี้ทำให้ผู้ใช้สามารถป้อนจำนวนแต่ละตัว คั่นด้วย , ได้
Scanner kb = new Scanner(System.in).useDelimiter("\\s*[,\\s]\\s*");
System.out.print("จำนวนทั้งสาม = ");
int a = kb.nextInt();
int b = kb.nextInt();
int c = kb.nextInt();
String sign = ""; // ใช้เครื่องหมาย + - x และ /
if (a+b == c)
{
sign = "+";
}
else if (a - b == c)
{
sign = "-";
}
else if (a * b == c)
{
sign = "x";
}
else if (a / b == c)
{
sign="/";
}
System.out.println("เครื่องหมายที่ต้องการคือ: " + sign);
}
}
|
SM=5, CM=27, ST=11, KY=686, TR=60:00
ERR = 60:00 ;
ERR = 60:00 ;
ERR = 60:00 ;
ERR = 60:00 ;
ERR = 60:00 ;
ERR = 60:00 ;
ERR = 60:00 ;
ERR = 60:00 ;
ERR = 60:00 ;
ERR = 60:00 ;
ERR = 60:00 ;
ERR = 60:00 ;
ERR = 60:00 ;
ERR = 60:00 ;
ERR = 60:00 ;
ERR = 60:00 ;
ERR = 60:00 ;
ERR = 60:00 ;
ERR = 60:00 ;
ERR = 60:00 ;
ERR = 60:00 ;
ERR = 60:00 ;
ERR = 60:00 ;
ERR = 60:00 ;
ERR = 60:00 ;
ERR = 60:00 ;
ERR = 60:00 ;
|
|