Note that there are some explanatory texts on larger screens.

plurals
  1. POGet Rank by Total
    primarykey
    data
    text
    <p>I have wrote below code.</p> <pre><code>import java.io.*; class Test { public static void main(String args[]) throws IOException { DataInputStream dis = new DataInputStream(System.in); String name[] = new String[10]; float s1[] = new float[10]; float s2[] = new float[10]; float s3[] = new float[10]; float s4[] = new float[10]; float tot[] = new float[10]; float avrg[] = new float[10]; float total = 0; float avg = 0; for (int i = 0; i &lt; 2; i++) { total = 0; avg = 0; System.out.println("Enter Name : "); String j = dis.readLine(); name[i] = j; System.out.println("Enter Mark1 : "); String y = dis.readLine(); float x = Float.parseFloat(y); s1[i] = x; System.out.println("Enter Mark2 : "); String n = dis.readLine(); float m = Float.parseFloat(n); s2[i] = m; System.out.println("Enter Mark3 : "); String v = dis.readLine(); float u = Float.parseFloat(v); s3[i] = u; System.out.println("Enter Mark4 : "); String a = dis.readLine(); float b = Float.parseFloat(a); s4[i] = b; total = x + m + u + b; tot[i] = total; avg = total / 4; avrg[i] = avg; } System.out.println(); System.out.println("Name" + "\t" + "Sub_1" + "\t" + "Sub_2" + "\t" + "Sub_3" + "\t" + "Sub_4" + "\t" + "Total" + "\t" + "Avg" + "\t" + "Rank"); System.out.println(); for (int k = 0; k &lt; 2; k++) { System.out.println(name[k] + "\t" + s1[k] + "\t" + s2[k] + "\t" + s3[k] + "\t" + s4[k] + "\t" + tot[k] + "\t" + avrg[k]); } System.out.println(); } } </code></pre> <p>Above code gave result like below.</p> <pre><code>Name Sub_1 Sub_2 Sub_3 Sub_4 Total Avg Rank A 10.0 10.0 20.0 10.0 50.0 12.5 B 20.0 20.0 30.0 10.0 80.0 20.0 </code></pre> <p>Now I want get <code>Rank</code> by <code>Total</code> and print output as below.</p> <pre><code>Name Sub_1 Sub_2 Sub_3 Sub_4 Total Avg Rank A 10.0 10.0 20.0 20.0 60.0 15.0 2 B 10.0 20.0 3.0 50.0 83.0 20.75 1 </code></pre> <p>How can i get <code>Rank</code> from <code>Total</code> ?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload