程序很简单,而且是自己分配的,所以不是家庭作业。
用户应该输入三个数字,显示平方的数字,并显示数字的总和。
import java.util.Scanner;
public class CompSquares {
public static void main (String args[]) {
Scanner s= new Scanner( System.in);
int num1;
System.out.println(" Enter a number please.");
num1 = s.next
我有一个Android问答应用程序,我正在构建学习kotlin / android应用程序开发。这是我拥有的一个对象,它是许多问题生成器之一。
有更好的方法来写这个吗?
package com.maxcell.sumitup
import java.security.SecureRandom
import kotlin.math.roundToInt
object MultiplicationFactory {
//What this code does by step
// step1 - I set 4 variables using a random
语言: java,我试图在我的代码中找到问题。有人能帮忙吗?
import java.util.Scanner;
public class LabProgram {
public static void int smallestNumber(int num1, int num2, int num3) {
int small = num3;
if (num1<num2 && num1<num3) {
small = num1;
}
else
我写了一个计算最小数的程序。但我不知道程序员会怎么做。我是通过"IF语句“来实现的,这是可行的,但不确定它是标准的还是通用的编码方式。
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner in = new Scanner(System.in);
System.out.print("Enter three values: ");
int num1 = in.nextInt();
int num2 = in.nextI
这是我在Stack Overflow上的第一个问题,请评论我如何提高我的提问能力。
所以基本上,我的Java代码中出现了一些随机错误,包括分号、花括号,有时还有其他随机字符。我不知道为什么它们时不时地出现--它们只是偶尔出现。我已经确保所有的括号都是成对的。以下是错误出现时间的示例:
public static *void* main(String[*]* args) *{*
public class TestClass {
int num1 = 1;
int num2 = 1;
int num3*;*
for(int
在标记所有这些重复之前,请查看代码,因为它是以与其他问题不同的方式完成的,我希望得到与此代码相关的修复。它基本上是一个计算器,它需要两个数字,然后一个运算符打印最后的数字(如果适用的话,还有一个余数)。我知道错误是:
The local variable num3 may not have been initialized
The local variable rem may not have been initialized
以下是代码:
import java.util.Scanner;
public class JCalc {
public static void main(Str
我想看看是否有办法改进我的代码,这个程序要求3位数,并计算出它是什么类型的三角形。
import java.util.Scanner;
public class Triangle{
public static void main (String[] args){
Scanner scan = new Scanner(System.in);
System.out.println("Enter 3 numbers that represent side of triangle (one by one): ");
int n
我需要一种更简单的方法来使用Python找到一组数字的平均值。我的代码又长又乏味,我不想花费更多的精力来添加5个以上的elif语句:
aom = input("How many numbers would you like to average?")
if str(aom) == '1':
num = input("Enter a number:")
listt = [num]
total = num
nums = (num)
elif str(aom) == '2':
num = inp
下面是我的c++代码。当我用c++17编译下面的代码时,我得到了一个类似这样的错误:“引用‘较大的’是模棱两可的。有人能帮助我吗?” #include <iostream>
using namespace std;
void greater(int num1, int num2, int num3);
int main()
{
int a, b, c;
cout<<"Enter three numbers"<<endl;
cin>>a>>b>>c;
greater(a,b,c);
return
这是一个程序,按照顺序排序三个输入的整数,从最少到最大。我想请你对它进行审查。
#include <iostream>
void Sort(int &a, int &b, int &c){
if(a>b){
int tmp = a;
a = b;
b = tmp;
}
if(a>c){
int tmp = a;
a=c;
c = tmp;
}
if(b>c){
int tmp = b;