Sunday, June 26, 2022

The Dice Problem

 The Dice Problem

Problem Statement
You are given a cubic dice with 6 faces. All the individual faces have a numbers printed on them. The numbers are in the range of 1 to 6, like any ordinary dice. You will be provided with a face of this cube, your task is to find the number on the opposite face of the cube.

import java.io.*; // for handling input/output
import java.util.*; // contains Collections framework


class Main {
    public static void main (String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=0;
        int t=sc.nextInt();
        for(int i=1;i<=t;i++)
        {
            n=sc.nextInt();
            if(n==1)
        {   System.out.println("6");
            
        }
        else if(n==2)
        {   System.out.println("5");
            
        }
        else if(n==3)
        {   System.out.println("4");
            
        }
        else if(n==4)
        {   System.out.println("3");
            
        }
        else if(n==5)
        {   System.out.println("2");
            
        }
        else if(n==6)
        {   System.out.println("1");
            
        }
                     
    }}}

No comments:

Post a Comment

ads vert

Basic HTML Tables - Layout, HTML Tables, Attributes, Aside, Footer, Tr tag, Td tag, Th tag, Tbody

  Basic HTML Tables - Layout, HTML Tables, Attributes, Aside, Footer, Tr tag, Td tag, Th tag, Tbody < table >      < thead >    ...