import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;/*
 * @(#) CSI1100.java
 * Created on 2004-10-4
 * By James Fancy
 *//**
 * CSI1100
 * 
 * @author James
 */
public class CSI1100 {    int hours;
    int minutes;
    int seconds;    public void printInfo() {
        System.out.println("CSI1100 Fall 2004, Assignment 2, Question 1d)");
        System.out.println("Name: Alan Williams, Student# 81069665");
        System.out.println("Lab section 999, TA: Grace Hopper");
        System.out.println();
    }    private int readInteger() throws IOException {
        BufferedReader bis = new BufferedReader(
            new InputStreamReader(System.in));
        String line = bis.readLine();
        try {
            return Integer.parseInt(line);
        } catch (NumberFormatException e) {
            return 0;
        }
    }    public void read() throws IOException {
        System.out.print("Enter the value for hours:");
        hours = readInteger();
        System.out.print("Enter the value for minutes:");
        minutes = readInteger();
        System.out.print("Enter the value for seconds:");
        seconds = readInteger();
        System.out.println();
    }    public static void main(String[] args) throws IOException {
        CSI1100 cst1100 = new CSI1100();
        cst1100.printInfo();
        cst1100.read();
        System.out.print("This duration contains ");
        System.out.print(new NumberOfSeconds(cst1100).getValue());
        System.out.println(" seconds.");
    }    public static class NumberOfSeconds {        long value;        public NumberOfSeconds(CSI1100 csi) {
            value = ((long) csi.hours) * 3600 + csi.minutes * 60 + csi.seconds;
        }        public long getValue() {
            return value;
        }
    }}

解决方案 »

  1.   

    没有 小弟弟一次接触java 
    什么都不知道 
    还望以后大哥多加提点
      

  2.   

    有没有qq或是msn之类的?? 可以让我有机会“多多”谢你
      

  3.   

    QQ:32485084
    QQ群:4187754Andrew1023(朱恩杰) 多编一些面向对象的程序,多看一些实例,思想慢慢就形成了。
      

  4.   

    这道题本身不难啊,主要是用英语写的大家才觉得难。
    题目本来就是一个时间转换来着。就是在输入输出的时候要做点文章。
    jamsfancy 用了一个静态的类放在main()函数的下面,想法不错,写的比我要好的多了,
    楼上大哥水平不赖哈!!
      

  5.   

    这个应该不难吧,把时间转化成以秒来计算的,只是锻炼大家的Java的基本使用能力罢了! 
    努力ing!
      

  6.   

    too simple  
    也就是大一的题
      

  7.   

    haodaniu(大牛),19212 / 3600 = 5小时
    19212 % 3600 = 1212 秒
    1212 / 60 = 20分钟
    1212 % 60 = 12秒
    这样算 5 小时 20 分钟 12 秒我觉得更好一些。
      

  8.   

    it's too easy, u should do ur assignments by urself, if it's really difficult, we can discuss it together.
      

  9.   

    what's the answer for 2b)?
    what is the assumption?