TechSapphire Sunday, 2018-12-16, 7:32 PM
Site menu
Login form
News
Play Games
  • Deep Freeze
  • Ice Slide
  • Gyroball
  • Fat Fish
  • Bush Royal Rampage
  • 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"); 
     }
     }
    }

    Click to download

    Categories
    Programming [27]
    Tips for programming
    Security [2]
    Security Tips
    Google [1]
    Use google faster then ever you use
    Project [14]
    HTML [2]
    Electronics [0]
    Data Structure [0]
    Database [16]
    SQL SERVER
    SSRS [1]
    Sql Server Reporting Services
    Copyright MyCorp © 2018