-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAss4.java
More file actions
23 lines (20 loc) · 747 Bytes
/
Ass4.java
File metadata and controls
23 lines (20 loc) · 747 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package com.google;
/*
Author :Vaibhavi
code for convert percentage to fraction
* */
public class Ass4 {
public static void main(String[] args) {
int per=30; //percentage = 30%
// To convert percentage into fraction simply remove % sign and divide that by 100
// we can reduce fraction further
int numerator=per;
int denominator=100;
// fraction = numerator / denominator
System.out.println(" Fraction of "+ per+" % is: "+numerator+"/"+denominator);
// to reuduce we can divide nume and denom by 10 ..both are divisible by 10..
numerator=per/10;
denominator=100/10;
System.out.println(" Fraction of "+ per+" % is: "+numerator+"/"+denominator);
}
}