You are not logged in. Please login at www.codechef.com to post your questions!

×

bit to byte

import java.util.*;

import javax.lang.model.util.ElementScanner6; class byteland { public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    System.out.println("Enter Test Cases:");
    int test_case = sc.nextInt();

    int[] ns = new int[test_case];
    int[] counter ={0,0,0};

    for(int i=0;i<ns.length;i++)
    {
        System.out.println("Enter ns:");
        ns[i] = sc.nextInt();    
    }
    System.out.println("This Output is:");
    for (int i = 0; i < test_case; i++) {

        int present_time=ns[i];

        if(present_time<=2)
            counter[0]++;
        else if(present_time>=3 && present_time<=8)
            counter[1]++;
        else if(present_time>=9 && present_time<=16)
            counter[2]++;
        else if(present_time>=17)
            counter[0]=counter[0]+2;
        else
            System.out.println("Invalid inputs");

        for (int j = 0; j <= 2; j++) {
            System.out.print(counter[j]);
            counter[j]=0;
        }

        System.out.println("");
    }
}

}

asked 14 Dec '18, 17:34

ferin79's gravatar image

0★ferin79
1
accept rate: 0%

You dont have to print "Enter no". print exactly whats asked in output

(14 Dec '18, 19:07) shivam_g14704★
toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×678
×130
×30
×19

question asked: 14 Dec '18, 17:34

question was seen: 52 times

last updated: 14 Dec '18, 19:07