I have been trying different things for 2 days now. Nothing I have tried seems to work. Below is how my code sits right now.
I am failing the 3rd and 5th task requirements.
Could somebody please tell me where my error(s) may be?
//write your code here
InputStream inputStream = System.in;
Reader inputStreamReader = new InputStreamReader(inputStream);
BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
String aIn = bufferedReader.readLine(); //Read 1st number from the keyboard to get the number
int nIn1 = Integer.parseInt(aIn); //convert first string to number
String aIn2 = bufferedReader.readLine(); //Read 2nd number from the keyboard to get the number
int nIn2 = Integer.parseInt(aIn); //convert second string to number
String aIn3 = bufferedReader.readLine(); //Read 3rd number from the keyboard to get the number
int nIn3 = Integer.parseInt(aIn); //convert third string to number
int count = 0;
if (nIn1 == 0)
{
// not positive OR negative - do nothing
}
else if (nIn1 > 0)
{
count++;
}
if (nIn2 == 0)
{
// not positive OR negative - do nothing
}
else if (nIn2 > 0)
{
count++;
}
if (nIn3 == 0)
{
// not positive OR negative - do nothing
}
else if (nIn3 > 0)
{
count++;
}
System.out.println(count);
package com.codegym.task.task04.task0428;
/*
Positive number
*/
import java.io.*;
public class Solution
{
public static void main(String[] args) throws Exception
{
//write your code here
InputStream inputStream = System.in;
Reader inputStreamReader = new InputStreamReader(inputStream);
BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
String aIn = bufferedReader.readLine(); //Read 1st number from the keyboard to get the number
int nIn1 = Integer.parseInt(aIn); //convert first string to number
String aIn2 = bufferedReader.readLine(); //Read 2nd number from the keyboard to get the number
int nIn2 = Integer.parseInt(aIn); //convert second string to number
String aIn3 = bufferedReader.readLine(); //Read 3rd number from the keyboard to get the number
int nIn3 = Integer.parseInt(aIn); //convert third string to number
int count = 0;
if (nIn1 == 0)
{
// not positive OR negative - do nothing
}
else if (nIn1 > 0)
{
count++;
}
if (nIn2 == 0)
{
// not positive OR negative - do nothing
}
else if (nIn2 > 0)
{
count++;
}
if (nIn3 == 0)
{
// not positive OR negative - do nothing
}
else if (nIn3 > 0)
{
count++;
}
System.out.println(count);
}
}