Java问题请帮忙! ! [英] Java question please help! !

查看:73
本文介绍了Java问题请帮忙! !的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习java但是我在学校的第一次测试中遇到了请帮助我,



包你好世界



/ **

*

* @author NETBEANS在这里放置您的初始价格

* /





import java.util.Scanner;



public class helloworld {



public static void main(String [] args){

//

 package prg420week1_codingassignment; 

/ **
*
* @author NETBEANS在这里放置您的初始价
* /


import java.util 。扫描器;

公共类PRG420Week1_CodingAssignment {

public static void main(String [] args){
//创建输入设备的可用实例
LINE 1.安装扫描仪并将其分配给各种类型的扫描仪。

//提示用户输入
LINE 2.使用打印()方法为他或她的第一个名字提示用户。

//捕获第一个单词并将其分配给A VARIABLE
LINE 3.使用您的扫描仪实例的下一个()方法为一个变量分配一个值。

//构造问候语
LINE 4.使用PRINTLN()方法构建一个正确的问候语。

}

}

我尝试过:

< pre> public static void main(String [] args){


//创建输入设备的可用实例
Scanner sc = new Scanner(System.in);
//提示用户输入
System.out.println(请输入你的名字:);
//捕获第一个单词并将其分配给A变量
String firstName;
firstName = sc.next();
//构造问候语
System.out.println(你好,+ sc.next()+!);

解决方案

请参阅扫描程序(Java Platform SE 7) [ ^ ]和系统(Java Platform SE 7) [ ^ ]。我在这里假设你的老师没有提供任何课程材料。


不,它不会 - 因为你还没有编写应该替换所有LINE n的代码线。该行描述了你要编写的代码是什么,它不是代码本身,需要被替换!



但是......我们没有做你的功课:这是有原因的。它就是为了让你思考你被告知的事情,并试着理解它。它也在那里,以便您的导师可以识别您身体虚弱的区域,并将更多的注意力集中在补救措施上。



亲自尝试,你可能会发现它不是和你想的一样困难!



如果遇到具体问题,请询问相关问题,我们会尽力提供帮助。但是我们不打算为你做这一切!


引用:

系统。 out.println(Hello,+ sc.next()+!);

to

 System.out.println(  Hello, + firstName +  ); <!/ pre> 

I'm learning java but I'm stuck in the first test in school please help me,

package hello world

/**
*
* @author NETBEANS PLACES YOUR INITIALS HERE
*/


import java.util.Scanner;

public class helloworld {

public static void main(String[] args) {
//

package prg420week1_codingassignment;

/**
 *
 * @author NETBEANS PLACES YOUR INITIALS HERE
 */


import java.util.Scanner;

public class PRG420Week1_CodingAssignment {
    
    public static void main(String[] args) {
        // Create a usable instance of an input device    
        LINE 1. INSTANTIATE AN INSTANCE OF SCANNER AND ASSIGN IT TO A VARIABLE OF TYPE SCANNER. 

        // Prompt user for input
        LINE 2. USE THE PRINT() METHOD TO PROMPT THE USER FOR HIS OR HER FIRST NAME.

        // Capture first word and assign it to A VARIABLE
        LINE 3. USE THE NEXT() METHOD OF YOUR SCANNER INSTANCE TO ASSIGN A VALUE TO A STRING VARIABLE.

        // Construct the greeting 
        LINE 4. USE THE PRINTLN() METHOD TO CONSTRUCT A CORRECTLY PUNCTUATED GREETING.

    }
    
}

What I have tried:

<pre>public static void main(String[] args) {


    // Create a usable instance of an input device
    Scanner sc = new Scanner(System.in);
    // Prompt user for input
    System.out.println("Please enter you first name:");
    // Capture first word and assign it to A Variable
    String firstName;
    firstName = sc.next();
    //Construct the greeting
    System.out.println("Hello, " + sc.next() + "!");

解决方案

See Scanner (Java Platform SE 7 )[^] and System (Java Platform SE 7 )[^]. I am assuming here that your teacher did not provide any course materials.


No, it won't - because you haven't written the code which should replace all of the "LINE n" lines. The line describes what the code you have to write is to do, it isn't teh code itself and needs to be replaced!

But ... We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is not as difficult as you think!

If you meet a specific problem, then please ask about that and we will do our best to help. But we aren't going to do it all for you!


Change from

Quote:

System.out.println("Hello, " + sc.next() + "!");

to

System.out.println("Hello, " + firstName + "!");


这篇关于Java问题请帮忙! !的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆