I started to learn java and was trying to write simple programs. Two similar programs but one of them is not working. Maybe somebody can explain me why?
This doesn't work:
public class Ex
{
public static void main(String[] args)
{
int number;
int second_power;
int third_power;
System.out.print ("Give the number: ");
number = .readInt();
second_power=number*number;
third_power=number*number*number;
System.out.println ("Number="+number);
System.out.println ("Second_power=" +second_power);
System.out.println ("Third_power=" +third_power);
}
}
and this works:
public class Ex
{
public static void main(String[] args)
{
int number;
int second_power;
int third_power;
System.out.print ("Give the number: ");
number = .readInt();
second_power=number*number;
third_power=number*number*number;
System.out.println ("Number="+number);
System.out.println ("Second_power=" +second_power);
System.out.println ("Third_power=" +third_power);
}
}

New Topic/Question
Reply




MultiQuote




|