hey guys i need help to

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Closed Thread

Join Date: Feb 2007
Posts: 4
Reputation: goofa is an unknown quantity at this point 
Solved Threads: 0
goofa goofa is offline Offline
Newbie Poster

hey guys i need help to

 
0
  #1
Feb 17th, 2007
1 import java.util.*;
2 publicclass CALC
3 {
4 publicstaticvoid main (String[] args)
5 { int much;
6 System.out.print("\nEnter the number of numbers ");
7 Scanner input=new Scanner(System.in);
8 much=input.nextInt();
9
10
11 int[]num=newint[much];
12 double[]perc=newdouble[num.length];
13
14 int[]den=newint[num.length];
15 int total=0;
16 int total1=0;
17 int perhold,smal;
18 double smallest,highest;
19 double percent;
20 int perc1;
21 int count=0;
22 double average;
23 for(int i=0;i<=num.length-1;i++)
24 {
25 System.out.print("Enter top number "+(i+1)+ " ");
26 num[i]=input.nextInt();
27 System.out.print("Enter the bottom number"+(i+1)+" ");
28 den[i]=input.nextInt();
29
30 perc[i]=(double)num[i]/(double)den[i];
31 perc[i]=perc[i]*100;
32 perc[i]=perc[i]+0.5;
33 perhold=(int)perc[i];
34 }
35
36 total=totalfind(num);
37 total1=totalfind(den);
38 average=(double)total/(double) total1;
39 percent=average*100.00;
40 percent=percent+0.5;
41 perc1=(int)percent;
42 System.out.print(" \n Grade percent average is "+ perc1+"%");
43
44 smallest=smallfind(perc); //here is the problem
45
46
47 System.out.print("\nthe smallest percent= " + smallest);
48
49
50
51
52 }//end main metod
53 publicstaticint totalfind(int[] number)
54 {
55 int tempt;
56 int tat=0;
57 for(int i=0;i<=number.length-1;i++)
58
59 tat=tat+number[i];
60 tempt=tat;
61 return tempt;
62 }
63 publicstaticint total2find(int[]dem1)
64 {
65 int tempt;
66 int tat2=0;
67 for(int i=0;i<=dem1.length-1;i++)
68 tat2=tat2+dem1[i];
69 tempt=tat2;
70 return tempt;
71 }
72
73 publicstaticint smallfind(int[]small)
74 {
75
76 int temp;
77 int index=0;
78 temp=small[0];
79 for(int i=1;i<=small.length-1;i++)
80 if(small[i]<temp)
81 {
82 temp=small[i];
83 index=i;
84 }
85 return index; //return the position of the smallest
86 }
87
88 //i supposed to find the average score percentage and lowest and highest percentage,
89
90
91
92
93
94
95
96
97
98 }
Quick reply to this message  
Join Date: Dec 2004
Posts: 4,273
Reputation: peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of 
Solved Threads: 494
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is online now Online
Code tags enforcer

Re: hey guys i need help to

 
0
  #2
Feb 17th, 2007
First thing first, when you copy and paste code can you please use tag for inserting code into post, which is the hash "#" sign on the toolbar for creating post. Thank you
Secondly please follow JAVA coding standarts, there are not there just for fun
  1. class naming CALC should be Calc or if you wish MyCalculationProgram
  2. methods totalfind should be totalFind
Third, what is purpose of for loop on lines 57, 67 & 79? They do actualy nothing, either put there braclets and some code between them or delete for loops
Fourth method smallfind is supposed to return the smallest percantage in your array, that is what you expect on line 44, in reality however you sending index position in the array not actual value from that position(line 83 assign array position to index, line 85 return this value)
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)

LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Quick reply to this message  
Join Date: Feb 2007
Posts: 4
Reputation: goofa is an unknown quantity at this point 
Solved Threads: 0
goofa goofa is offline Offline
Newbie Poster

Re: hey guys i need help to

 
0
  #3
Feb 17th, 2007
i am new at programing this is my frist month,
For line57,67 & 79 ;that is to limit the array to the numbers of position that the user entered.
and for returning index position is because i want the smallest percentage and the smallest score e.g:the lowest score is 12/50 which is ...%
and thank you
Quick reply to this message  
Closed Thread

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Java Forum


Views: 1000 | Replies: 2
Thread Tools Search this Thread



Tag cloud for Java
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC