请问各位大师,下面这个程序出现Input cannot be resolved to a type这个怎么解决
importjava.io.PrintStream;publicclassf{privatevoidT(){finalInputin=newInput();System....
import java.io.PrintStream;
public class f {
private void T()
{
final Input in=new Input();
System.out.print("Enter the first:");
final double a=in.nextDouble();
System.out.print("enter the second:");
final double b=in.nextDouble();
System.out.print("enter the third:");
final double c=in.nextDouble();
if((a+b)>c&&(a+c)>b&&(b+c)>a)
{
final double p=a+b+c;
final double s=0.5*p;
final double v=s*(s-a)*(s-b)*(s-c);
System.out.println("p is"+p);
System.out.println("s is"+s);
System.out.println("v is"+v);
}
else
{
System.out.println("你的数字不能构成一个三角形");
}
}
public static void main(final String[]args)
{
f object=new f();
object.T();
}
} 展开
public class f {
private void T()
{
final Input in=new Input();
System.out.print("Enter the first:");
final double a=in.nextDouble();
System.out.print("enter the second:");
final double b=in.nextDouble();
System.out.print("enter the third:");
final double c=in.nextDouble();
if((a+b)>c&&(a+c)>b&&(b+c)>a)
{
final double p=a+b+c;
final double s=0.5*p;
final double v=s*(s-a)*(s-b)*(s-c);
System.out.println("p is"+p);
System.out.println("s is"+s);
System.out.println("v is"+v);
}
else
{
System.out.println("你的数字不能构成一个三角形");
}
}
public static void main(final String[]args)
{
f object=new f();
object.T();
}
} 展开
2个回答
展开全部
把这句final Input in=new Input();改成final Scanner in=new Scanner(System.in);再导入import java.util.Scanner;就行了。完整的程序如下:(改动的地方见注释)
import java.io.PrintStream;
import java.util.Scanner; //这里加一句
public class f {
private void T()
{
final Scanner in=new Scanner(System.in);//这里改了一句
System.out.print("Enter the first:");
final double a=in.nextDouble();
System.out.print("enter the second:");
final double b=in.nextDouble();
System.out.print("enter the third:");
final double c=in.nextDouble();
if((a+b)>c&&(a+c)>b&&(b+c)>a)
{
final double p=a+b+c;
final double s=0.5*p;
final double v=s*(s-a)*(s-b)*(s-c);
System.out.println("p is"+p);
System.out.println("s is"+s);
System.out.println("v is"+v);
}
else
{
System.out.println("你的数字不能构成一个三角形");
}
}
public static void main(final String[]args)
{
f object=new f();
object.T();
}
}
运行结果:
Enter the first:34.2
enter the second:32.6
enter the third:43.6
p is110.4
s is55.2
v is303895.87200000003
import java.io.PrintStream;
import java.util.Scanner; //这里加一句
public class f {
private void T()
{
final Scanner in=new Scanner(System.in);//这里改了一句
System.out.print("Enter the first:");
final double a=in.nextDouble();
System.out.print("enter the second:");
final double b=in.nextDouble();
System.out.print("enter the third:");
final double c=in.nextDouble();
if((a+b)>c&&(a+c)>b&&(b+c)>a)
{
final double p=a+b+c;
final double s=0.5*p;
final double v=s*(s-a)*(s-b)*(s-c);
System.out.println("p is"+p);
System.out.println("s is"+s);
System.out.println("v is"+v);
}
else
{
System.out.println("你的数字不能构成一个三角形");
}
}
public static void main(final String[]args)
{
f object=new f();
object.T();
}
}
运行结果:
Enter the first:34.2
enter the second:32.6
enter the third:43.6
p is110.4
s is55.2
v is303895.87200000003
展开全部
import java.util.Scanner;
public class Test {
public void T() {
Scanner in = new Scanner(System.in);
System.out.print("Enter the first:");
double a = in.nextDouble();
System.out.print("enter the second:");
double b = in.nextDouble();
System.out.print("enter the third:");
double c = in.nextDouble();
if ((a + b) > c && (a + c) > b && (b + c) > a) {
double p = a + b + c;
double s = 0.5 * p;
double v = s * (s - a) * (s - b) * (s - c);
System.out.println("p is " + p);
System.out.println("s is " + s);
System.out.println("v is " + v);
} else {
System.out.println("你的数字不能构成一个三角形");
}
}
public static void main(final String[] args) {
Test object = new Test();
object.T();
}
}
这样写……
public class Test {
public void T() {
Scanner in = new Scanner(System.in);
System.out.print("Enter the first:");
double a = in.nextDouble();
System.out.print("enter the second:");
double b = in.nextDouble();
System.out.print("enter the third:");
double c = in.nextDouble();
if ((a + b) > c && (a + c) > b && (b + c) > a) {
double p = a + b + c;
double s = 0.5 * p;
double v = s * (s - a) * (s - b) * (s - c);
System.out.println("p is " + p);
System.out.println("s is " + s);
System.out.println("v is " + v);
} else {
System.out.println("你的数字不能构成一个三角形");
}
}
public static void main(final String[] args) {
Test object = new Test();
object.T();
}
}
这样写……
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询