Question : You have a blue lottery ticket, with ints a, b, and c on it. This makes three pairs, which we'all call ab, bc, ac. Consider the sum of the numbers in each pair. If any pair sums to exactly 10, the result is 10. Otherwise if the ab sum is exactly 10 more than either bc or ac sums, the result is 5. Otherwise the result is 0.
Output:
9, 1, 0 -> 10
9, 2, 0 -> 0
6, 1, 4 -> 10
Answer :
import java.util.*; public class LotteryTicket { public static void main(String[] args) { Scanner sc=new Scanner(System.in); System.out.println("Enter num 1 of ticket : "); int Num1=sc.nextInt(); System.out.println("Enter num 2 of ticket : "); int Num2=sc.nextInt(); System.out.println("Enter num 3 of ticket : "); int Num3=sc.nextInt(); if(Num1+Num2 ==10 || Num2+Num3==10 || Num1+Num3==10) { System.out.println("10"); } else if (Num1+Num2-10==Num2+Num3 || Num1+Num2-10==Num1+Num3) { System.out.println("5"); } else { System.out.println("0"); } } }