我如何...在main中创建以下三个变量,一个名为mydbl的double,一个名为anotherdbll的double,一个名为myint的int ... [英] How do i...in main create the following three variables a double named mydbl a double named anotherdbll an int named myint...

查看:102
本文介绍了我如何...在main中创建以下三个变量,一个名为mydbl的double,一个名为anotherdbll的double,一个名为myint的int ...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在main中创建以下三个变量



一个名为myDbl的双重



一个名为anotherDbll的double



名为myInt的int



使用从键盘获取的数据填充每个变量。您将不得不创建Scanner类的实例来执行此操作。一旦变量中包含数据,就对每个变量执行以下操作



使用unaray运算符将myDbl增加一个



使用快捷操作符将AnotherDbl减少两个



使用一元运算符将myInt减少一个







您的输出应如下所示:

图片链接是否正常工作?





[ ^ ]



我尝试过:



包创建。变量;



/ **

*

* @author stephenwessels

* /

import java.util.Scanner;

公共类CreatingVariables

{



/ **

* @param args命令行参数

* /

public static void main(String [] args)

{

Scanner in = new Scanner(System.in) ;



双myDbl,anotherDll;

int myInt;



系统.out.println(输入两个双打和一个int:);

myInt = in.nextInt();

myDbl = in.nextDouble();

anotherDbll = in.nextDouble();





System.out.println(这是你修改过的数字);







}



}

这是我到目前为止。

解决方案

所以,你没有尝试自己解决问题,你有毫无疑问,你只是想让我们去做我们的家庭工作。

家庭工作问题是你在现实生活中必须解决的问题的简化版本,他们的目的是学习和练习



我们不做你的HomeWork。

HomeWork不会测试你乞求别人做你的工作的技巧,它是让您思考并帮助您的老师检查您对所学课程的理解以及您应用这些课程时遇到的问题。

你的任何失败都会帮助你的老师发现你的弱点并设定补救措施。

你的任何失败都会帮助你了解什么有效,什么无效,被称为'试错'学习。

所以,试一试,重读课程并开始工作。如果您遇到特定问题,请显示您的代码并解释这个问题,我们可能会提供帮助。

Quote:

我根本不知道该怎么做



编程是组装基本集团以获得理想结果的艺术。

你必须开始通过分析问题并将其分解为一系列较小/较简单的问题并重复,直到问题变得简单,以便您可以转换为代码。

- 学习一种或多种分析方法, EW Djikstra自上而下的方法是一个良好的开端。

https:// en.wikipedia.org/wiki/Top-down_and_bottom-up_design [ ^ ]

https://en.wikipedia.org/wiki/Structured_programming [ ^ ]

https://en.wikipedia.org/wiki/Edsger_W._Dijkstra [ ^ ]

https://www.cs.utexas.edu/users/EWD/ewd03xx/EWD316.PDF [ ^ ]


到目前为止我所拥有的。 package creating.variables;



/ **

*

* @author stephenwessels

* /

import java.util.Scanner;

公共类CreatingVariables

{



/ **

* @param args命令行参数

* /

public static void main(String [ ] args)

{

Scanner in = new Scanner(System.in);



double myDbl, anotherDll;

int myInt;



System.out.println(输入两个双打和一个int:);

myInt = in.nextInt();

myDbl = in.nextDouble();

anotherDbll = in.nextDouble();





System.out.println(这是你修改过的数字);



< br $> b $ b

}



}

没关系,我能够弄明白。


In main create the following three variables

A double named myDbl

A double named anotherDbll

An int named myInt

Fill each of the variables with data taken from the keyboard. You are going to have to create an instance of the Scanner class to do this. Once the variables have data in them do the following to each variable

Increment myDbl by one using a unaray operator

Decrement anotherDbl by two using a shortcut operator

Decrement myInt by one using a unary operator



Your output should look like the following:
does the picture link work?


[^]

What I have tried:

package creating.variables;

/**
*
* @author stephenwessels
*/
import java.util.Scanner;
public class CreatingVariables
{

/**
* @param args the command line arguments
*/
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);

double myDbl, anotherDbll;
int myInt;

System.out.println("Enter two doubles and an int:");
myInt = in.nextInt();
myDbl = in.nextDouble();
anotherDbll = in.nextDouble();


System.out.println("Here are your numbers modified");



}

}
This is what I have so far.

解决方案

So, you show no attempt to solve the problem yourself, you have no question, you just want us to do your HomeWork.
HomeWork problems are simplified versions of the kind of problems you will have to solve in real life, their purpose is learning and practicing.

We do not do your HomeWork.
HomeWork is not set to test your skills at begging other people to do your work, it is set to make you think and to help your teacher to check your understanding of the courses you have taken and also the problems you have at applying them.
Any failure of you will help your teacher spot your weaknesses and set remedial actions.
Any failure of you will help you to learn what works and what don't, it is called 'trial and error' learning.
So, give it a try, reread your lessons and start working. If you are stuck on a specific problem, show your code and explain this exact problem, we might help.

Quote:

I simply don't know what to do for this


Programming is the art of assembling basic blocs to get desired result.
You have to start by an analyze of the problem and break it into a sequence of smaller/simpler problems and repeat until problems are simple enough so you can translate to code.
- Learn one or more analyze methods, E.W. Djikstra top-Down method is a good start.
https://en.wikipedia.org/wiki/Top-down_and_bottom-up_design[^]
https://en.wikipedia.org/wiki/Structured_programming[^]
https://en.wikipedia.org/wiki/Edsger_W._Dijkstra[^]
https://www.cs.utexas.edu/users/EWD/ewd03xx/EWD316.PDF[^]


Heres what I have so far. package creating.variables;

/**
*
* @author stephenwessels
*/
import java.util.Scanner;
public class CreatingVariables
{

/**
* @param args the command line arguments
*/
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);

double myDbl, anotherDbll;
int myInt;

System.out.println("Enter two doubles and an int:");
myInt = in.nextInt();
myDbl = in.nextDouble();
anotherDbll = in.nextDouble();


System.out.println("Here are your numbers modified");



}

}


Never mind, I was able to figure it out.


这篇关于我如何...在main中创建以下三个变量,一个名为mydbl的double,一个名为anotherdbll的double,一个名为myint的int ...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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