pages:
  • 1
AR.Fereydouni SAYS

Please tell me how should I present the result? Please use java syntax exactly I tried about for diffrent ways but got presentation error Help me!!!

K.Razavi SAYS

maybe this sentence : where the value of a and b are for you to determine. A blank line should separate output lines. it means you must print one empty line between outputs .(NOT after each output)

AR.Fereydouni SAYS

I did it but got presentation error again!!! I read a code that accepted but ... !

AR.Fereydouni SAYS

My code:

package Sharecode;

//In The Name of Allah

import java.util.Scanner;

public class P6001 { public static void main(String[] args) { Scanner inkb = new Scanner(System.in); short n = inkb.nextShort(); short A, B; if (n != 0) { boolean is = true; do { A = 0; B = 0; short[] a = new short[n]; for (short i = 0; i < a.length; i++) { a[i] = inkb.nextShort(); } short[] b = new short[n]; for (short i = 0; i < b.length; i++) { b[i] = inkb.nextShort(); } for (short i = 0; i < n; i++) { if ((a[i] + b[i]) == 3) { if (a[i] == 1) A += 6; else B += 6; } else if ((a[i] - b[i]) == 1) B += (a[i] + b[i]); else if ((b[i] - a[i]) == 1) A += (a[i] + b[i]); else if (a[i] > b[i]) A += a[i]; else if (b[i] > a[i]) B += b[i]; } System.out.print("A has " + A + " points. B has " + B + " points."); n = in_kb.nextShort(); if (n != 0) System.out.print("\n\n"); } while (n != 0); } } }

*RONALDO* SAYS

hi 11 11 !

I found some problems here.

  1. after first testcase when the result printed you should give a blank line if the next number is (!=0). but if you pay attention the cursor stay at the end of line and don't leave blank line... I suggest you use inkb.hasnextshort() in a way to determine blank line should be or no. somewhere here : (n = in_kb.nextShort(); if (n != 0) System.out.print("\n\n");)

  2. pay attention don't give a blank line after last output

if you use online compilers don't trust ...even your answer is right... use JDK or netbeans to see exactly what is happening.

AR.Fereydouni SAYS

thanks all!!!

I fixed the code and got the Accepted result

Best Regards!