gpt4 book ai didi

Java-程序不显示输出

转载 作者:行者123 更新时间:2023-12-01 11:17:10 25 4
gpt4 key购买 nike

我是 Java 新手,目前正在制作一个程序,显示两年的年度总计和平均值,问题是它没有显示任何输出,我不知道为什么,有人可以帮助我吗?谢谢。

import java.util.Scanner;

public class Main {

static Scanner in = new Scanner(System.in);

public static void main(String[] args) {
String[] months = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
double[] monthlyIncomes = new double[12];
String[] months2015 = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
double[] monthlyIncomess = new double[12];
double total = 0;
double average = 0;
double max = 0;
double min = 0;
double n;

for (int i = 0; i < monthlyIncomes.length; i++) {
System.out.println("Enter income for " + months[i] + " 2014 :");
monthlyIncomes[i] = in.nextDouble();
}
for (int i = 0; i < monthlyIncomess.length; i++) {
System.out.println("Enter income for " + months2015[i] + " 2015 :");
monthlyIncomess[i] = in.nextDouble();
}
}

static void Max(double n, double max, double min, double [] monthlyIncomes) {
for (int i = 0; i < monthlyIncomes.length; i++) {
if (monthlyIncomes[i] > max) {
max = monthlyIncomes[i];
}
}
max = in.nextDouble();
System.out.println("Largest income is: " + max );
}


static void Min(double n, double max, double min, double [] monthlyIncomes) {
for (int i = 0; i < monthlyIncomes.length; i++){
if (monthlyIncomes[i] < min) {
min = monthlyIncomes[i];
}
}
min = in.nextDouble();
System.out.println("Smallest income is: " + min);
}

static void total(double total, double [] monthlyIncomes) {
for (int i = 0; i < monthlyIncomes.length; i++)
total = total + monthlyIncomes[i];
total = in.nextDouble();
System.out.println("The total is : " + total);
}

static void average(double average,double total, double [] monthlyIncomes) {
for (int i = 0; i < monthlyIncomes.length; i++)
average = total/12;
average = in.nextDouble();
System.out.println("The average income is :" + average);
}

static void max(double max, double [] monthlyIncomes2015) {
for (int i = 0; i < monthlyIncomes2015.length; i++) {
if (monthlyIncomes2015[i] > max) {
max = monthlyIncomes2015[i];
}
}
max = in.nextDouble();
System.out.println("The largest income for 2015 is :" + max);
}

static void min(double min, double [] monthlyIncomes2015) {
for (int i = 0; i < monthlyIncomes2015.length; i++) {
if (monthlyIncomes2015[i] < min){
min = monthlyIncomes2015[i];
}
}
min = in.nextDouble();
System.out.println("The smallest income for 2015 is :" + min);
}

static void total2(double total, double [] monthlyIncomess) {
for (int i = 0; i < monthlyIncomess.length; i++)
total = total + monthlyIncomess[i];
total = in.nextDouble();
System.out.println("The total for 2015 is : " + total);
}

static void average2(double total, double average, double [] monthlyIncomess) {
for (int i = 0; i < monthlyIncomess.length; i++)
average = total/12;
average = in.nextDouble();
System.out.println("The average income is :" + average);
}
}

最佳答案

问题是 main() 没有调用其他函数,例如 max min avg 和 Total

关于Java-程序不显示输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31682269/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com