-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathonline or offline
55 lines (40 loc) · 1.55 KB
/
online or offline
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
Problem
Chef is confused whether to go out and eat at the restaurant or order food online.
The online order costs N rupees while the cost of eating at the restaurant is M rupees.
However, Chef has a discount coupon with which he can avail flat 10% off on his online order.
Find the cheaper option for Chef to eat, i.e., whether to order food online or eat at the restaurant.
Explanation:
Test case 1: The final price of ordering online would be 500−(10% of 500)=450 which is less than the price of dining.
Thus, Chef should order online.
Test case 2: The final price of ordering online would be 500−(10% of 500)=450 which is not less than 400.
Thus, Chef should choose dining option.
Test case 3: Even after the 10% discount, cost of ordering online is higher.
Thus, Chef should choose dining option.
Test case 4: After 10% discount, cost of ordering online is 90.
The costs of ordering online and dining at restaurant are same. Thus, Chef can choose any option.
/* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
for(int i=0;i<t;i++){
int x=sc.nextInt();
int y=sc.nextInt();
double z=x-(0.1*x);
if(z<y){
System.out.println("ONLINE");
}if(z>y){
System.out.println("DINING");
}if(z==y){
System.out.println("EITHER");
}
}
// your code goes here
}
}