佳礼资讯网

 找回密码
 注册

ADVERTISEMENT

查看: 855|回复: 1

请帮忙。。。。。我做到已经很晕了!!!

[复制链接]
发表于 28-1-2007 05:58 PM | 显示全部楼层 |阅读模式
请大家帮忙(java)

以下是我做的,可是都compile不到。。。。请大家帮我纠正。。。。谢谢!!请大家帮帮忙。。。。明天就要交了


import java.io.*;
public class can
{
  
String candidate;
int vote;
double percentage;

public void readData()throws IOException
{
  InputStreamReader read=new InputStreamReader(System.in);
  BufferedReader input=new BufferedReader(read);
  
  System.out.print("Candidate";
  candidate=input.readLine();
  System.out.print("Votes Receive";
  vote=Integer.parseInt(input.readLine());
}

public void printInfo()
{
  System.out.println(candidate + "\t"+vote+"\t\t"+percentage);
}

public double calculateAverage()
{
  percentage=(vote/19300)/5;
}

public static void main(String[]args)throws IOException
{
  Student[] studDegree;
  studDegree=new Student[5];
  
  for(int i=0;i<studDegree.length;i++)
  {
   studDegree=new Student();
   studDegree.readData();
  }
  
  for(int i=0;i<studDegree.length;i++)
  {
   studDegree.calculateAverage();
   studDegree.printInfo();
  }
}
}


***********************************************************
以下是老师的问题和要的答案:


  • Write a program that allows the user to enter the names of five candidates in a local election and votes received by each candidates. The program should then output each candidate’s name, the votes received by that candidate, and the percentage of the total votes received  by the candidate. Your program should also output the winner of the election. A sample output is:

Candidates     Votes Received    % of Total Votes
   Asmah         5000             25.91
   Johan         4000             20.72
   Daud          6000             31.09
   Roslan        2500             12.95
   Ali           1800             9.33
   Jumlah        19300
   Pemenang ialah   Daud

回复

使用道具 举报


ADVERTISEMENT

发表于 30-1-2007 01:26 AM | 显示全部楼层
首先... compile 不到, 你的 error message 呢?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

 

ADVERTISEMENT


本周最热论坛帖子本周最热论坛帖子

ADVERTISEMENT



ADVERTISEMENT

ADVERTISEMENT


版权所有 © 1996-2023 Cari Internet Sdn Bhd (483575-W)|IPSERVERONE 提供云主机|广告刊登|关于我们|私隐权|免控|投诉|联络|脸书|佳礼资讯网

GMT+8, 27-8-2025 06:50 AM , Processed in 0.102004 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表