Monday, June 20, 2022


Nobits's Test
Problem Statement
Nobita wants to score well in his upcoming test, but he is not able to solve the simple division problems, seeing Nobita's determination Doraemon gives him a gadget that can do division problems easily but somehow Nobita deleted the internal program which calculates the division.
As an excellent coder, Nobita came to you for help. Help Nobita to write a code for his gadget.
You will be given two integers D and Q, you have to print the floor value of D/Q



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 D=sc.nextInt();
                      int Q=sc.nextInt();
int res = 0;
                if(Q<=100 && 0<=Q&&0<=D &&D<=100)
                if(Q==0)    {
System.out.println("-1");
}
                    else
                    {
     res = D/Q;
    if(res>=0){
System.out.println(res);
}
                    }

    }
}

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 >    ...