forked from cognizance-amrita/hacktoberfest
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue cognizance-amrita#58 : Solved in java
resolves cognizance-amrita#58 Finding_the_percentage question in java.
- Loading branch information
1 parent
61431b1
commit 231c2df
Showing
1 changed file
with
23 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} | ||
} |