Skip to content

Commit

Permalink
Issue cognizance-amrita#58 : Solved in java
Browse files Browse the repository at this point in the history
resolves cognizance-amrita#58 Finding_the_percentage question in java.
  • Loading branch information
jaichiranjeeva committed Oct 24, 2022
1 parent 61431b1 commit 231c2df
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions java/Finding_the_percentage.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import java.util.Scanner;

public class Finding_the_percentage{
public static void main(String[] args) {
Scanner in=new Scanner(System.in);
int len=in.nextInt();
String[] data= new String[len];
int i;
in.nextLine(); // dump , as the loop body nextLine func returns the return(enter) value given when reading int value
for(i=0;i<len;i++){
data[i]=in.nextLine();
}
String req=in.next();
for(i=0;i<len;i++){
String[] line = new String[4];
line = data[i].split(" ");
if(line[0].equals(req)){
System.out.printf("%,.2f",
(Double.parseDouble(line[1])+Double.parseDouble(line[2])+Double.parseDouble(line[3]))/3.0);
}
}
}
}

0 comments on commit 231c2df

Please sign in to comment.