ยินดีต้อนรับคุณ, บุคคลทั่วไป กรุณา เข้าสู่ระบบ หรือ ลงทะเบียน

เข้าสู่ระบบด้วยชื่อผู้ใช้ รหัสผ่าน และระยะเวลาในเซสชั่น

ThaiSEOBoard.comความรู้ทั่วไปGeneral (ถามคุยวิชาการ IM)ช่วยผมหน่อยครับ โปรแกรมแปลงเวลา java
หน้า: [1]   ลงล่าง
พิมพ์
ผู้เขียน หัวข้อ: ช่วยผมหน่อยครับ โปรแกรมแปลงเวลา java  (อ่าน 572 ครั้ง)
0 สมาชิก และ 1 บุคคลทั่วไป กำลังดูหัวข้อนี้
phongsit32
ก๊วนเสียว
*

พลังน้ำใจ: 10
ออฟไลน์ ออฟไลน์

กระทู้: 266



ดูรายละเอียด
« เมื่อ: 24 กันยายน 2013, 02:56:54 »

ช่วยผมหน่อยครับ  โปรแกรมแปลงเวลา java
แต่ต้องแปลงการเป็น oop ทำไงครับ
โค๊ด:
package program;
import java.util.Scanner;
public class Program {
public static void main(String[] args) {
Scanner In = new Scanner(System.in);
int num;
System.out.println("----------------------------------------------");
System.out.println("ProGram Second To Time Converter");
System.out.println("----------------------------------------------");
System.out.println("1.Second-> Minute");
System.out.println("2.Minute-> Second");
System.out.print("Please Select Your Choice:");
num =In.nextInt();
 switch (num){
 case 1:
System.out.print("input Second:");    
int sec, sec1, min;
sec = In.nextInt();
min = (int)sec / 60; // 1 minute = 60 seconds
sec1 = sec % 60; // remainder in seconds after converted to min

System.out.println(sec + " Seconds is (MM:SS) "  + min + ":" + sec1 + ".");
break;
    
  case 2:
System.out.print("input Minute:");    
int secc, sec11, minn,seccc;
secc = In.nextInt();
System.out.print("input Second:");
seccc=In.nextInt();
minn = (int)secc * 60+seccc; // 1 minute = 60 seconds
sec11 = secc % 60; // remainder in seconds after converted to min
System.out.println(sec11 + "Minute" + seccc + " Second is (SS) "+ minn + ".");
break;  
    
    
}
} }

+1
« แก้ไขครั้งสุดท้าย: 24 กันยายน 2013, 03:01:36 โดย phongsit32 » บันทึกการเข้า

VPS digitaloceanaฟรีโบนัส $10
คูปองรับโบนัสรับ$10  SHIPITFAST10

index ไว ภายใน 72 ชั่งโมง .
หน้า: [1]   ขึ้นบน
พิมพ์