whats wrong with this program?/**Ex25.java* Ex25-To accept a three-digit number * and display the digit each on a single line,* and the sum of these digits.*@author *@version Oct.14.2010*/import java.awt.*;import java.util.Scanner;public class Ex25{p

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/30 05:20:21
whats wrong with this program?/**Ex25.java* Ex25-To accept a three-digit number * and display the digit each on a single line,* and the sum of these digits.*@author *@version Oct.14.2010*/import java.awt.*;import java.util.Scanner;public class Ex25{p
xV]O0+ViiZm/e<ĤI{/hڃSz7- w'Cihkקxp4l3X„a u|ugׇ|Cf892NZ ,d)ɜ[8aPQL%KȡQX.MbdTd-Q#h):OHL#"(<-49GyHUSͧ =C gP6*9R R:ϫueMD۬w>6˱APV3f&ܰj\HAUgF4 wHiZdjLt\fߨR(H~N%fݿUOC9:A悏py"]-BA%>b@uD}v8Yh2wCM!]#LxO $@8=vf%}-O+nfg 󯮳be[YՃ2k+ p_\/>~LGyAS׻w~}t?yBzF^5^4?zo$ѿûwZsU@VJn IVRvZfRB DrEڶFbXs8)Q'e"0u&B

whats wrong with this program?/**Ex25.java* Ex25-To accept a three-digit number * and display the digit each on a single line,* and the sum of these digits.*@author *@version Oct.14.2010*/import java.awt.*;import java.util.Scanner;public class Ex25{p
whats wrong with this program?
/**Ex25.java
* Ex25-To accept a three-digit number
* and display the digit each on a single line,
* and the sum of these digits.
*@author
*@version Oct.14.2010
*/
import java.awt.*;
import java.util.Scanner;
public class Ex25
{
private String hundredDigit,tenDigit,digit;
private int hd,td,d;
private double n;
private double sum,s;
public Ex25()
{
hundredDigit=getHundredDigit();
tenDigit=getTenDigit();
digit=getDigit();
hd();
td();
d();
sum();
}
public int getHundreDigit()
{
Scanner sc=new Scanner(System.in);
System.out.print("Enter the hundredDigit:");
hundredDigit=sc.nextLine();
hd=Integer.parseInt(hundredDigit);
return hd;
}
public int getTenDigit()
{
Scanner sc=new Scanner(System.in);
System.out.print("Enter the tenDigit:");
tenDigit=sc.nextLine();
td=Integer.parseInt( tenDigit);
return td;
}
public int getDigit()
{
Scanner sc=new Scanner(System.in);
System.out.print("Enter the digit:");
digit=stdin.readLine();
d=Integer.parseInt(digit);
return d;
}
public void hundredigit()
{
hd=n/100;
System.out.println("The hundredDigit is:");
}
public void TenDigit()
{
td=((tn1*10)+(sn*1))/10;
System.out.println("The tensDigit is:");
}
public void Digit()
{
d=(n/100)%10;
System.out.println("The digit is:");
}
public void sum()
{
s=hd+td+d;
System.out.println("The hundredDigit is "+hd+"the tenDigit is "+td+"the digit is "+d+"The sum is:");
}
public static void main(String[]args)
{
Ex25 ex25=new Ex25();
}
}

whats wrong with this program?/**Ex25.java* Ex25-To accept a three-digit number * and display the digit each on a single line,* and the sum of these digits.*@author *@version Oct.14.2010*/import java.awt.*;import java.util.Scanner;public class Ex25{p
/**Ex25.java
* Ex25-To accept a three-digit number
* and display the digit each on a single line,
* and the sum of these digits.
*@author
*@version Oct.14.2010
*/
import java.awt.*;
import java.util.Scanner;
public class Ex25
{
private String hundredDigit,tenDigit,digit;
private int hd,td,d;
private double n;
private double sum,s;
public Ex25()
{
hundredDigit=getHundredDigit();
tenDigit=getTenDigit();
digit=getDigit();
Hundredigit();
TenDigit();
Digit();
sum();
}
public int getHundreDigit()
{
Scanner sc=new Scanner(System.in);
System.out.print("Enter the hundredDigit:");
hundredDigit=sc.nextLine();
hd=Integer.parseInt(hundredDigit);
n+=hd*100;
return hd;
}
public int getTenDigit()
{
Scanner sc=new Scanner(System.in);
System.out.print("Enter the tenDigit:");
tenDigit=sc.nextLine();
td=Integer.parseInt( tenDigit);
n+=td*10;
return td;
}
public int getDigit()
{
Scanner sc=new Scanner(System.in);
System.out.print("Enter the digit:");
digit=stdin.readLine();
d=Integer.parseInt(digit);
n+=d;
return d;
}
public void Hundredigit()
{
hd=n/100;
System.out.println("The hundredDigit is:");
}
public void TenDigit()
{
td=n/10-hd*10;
System.out.println("The tensDigit is:");
}
public void Digit()
{
d=n%10;
System.out.println("The digit is:");
}
public void sum()
{
s=hd+td+d;
System.out.println("The hundredDigit is "+hd+"the tenDigit is "+td+"the digit is "+d+"The sum is:");
}
public static void main(String[]args)
{
Ex25 ex25=new Ex25();
}
}
The name of function you declare and call is not the same.
You don't initialize n when user input the three numbers.
Don't use a same name for both function and variable,it will cause an error.