whats wrong with this program?
来源:学生作业帮 编辑:搜搜考试网作业帮 分类:综合作业 时间:2024/06/05 12:01:26
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();
}
}
/**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();
}
}
/**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.
* 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.
whats wrong with this program?
whats wrong with
what is wrong with the following program?
Whats wrong with it(SD-invoice-post to account)?
whats wrong 的回答
Its time to have class.同义句Whats wrong witn you?同义句With these
whats this 复数句子
WHATS THIS MOVIESS NAME
知趣竞猜Whats this?
whats this
whats with the mask
Can you_____what is wrong with this recorder?