- Joined
- Feb 11, 2008
- Messages
- 607 (0.10/day)
- Location
- Omaha, Nebraska, USA
System Name | Built By Me |
---|---|
Processor | Intel Core i9 9900K @ 5.1 GHz |
Motherboard | Gigabyte Z390 Aorus Ultra |
Cooling | Custom Water Cooling - CPU Only |
Memory | 32GB (2 x 16) GSkill Ripjaws V DDR4 |
Video Card(s) | RTX 4080 - ASUS ROG Strix 16GB OC - P Mode |
Storage | 1TB Samsung 970 Evo NVMe |
Display(s) | Alienware AW2723DF @ 280 Hz @ 1440P |
Case | Fractal Design Define S2 |
Audio Device(s) | Corsair Virtuoso Pro |
Power Supply | 850W Seasonic Platinum |
Mouse | Razer Viper V2 Pro @ 2k Hz |
Keyboard | Asus ROG Strix Scope II 96 Wireless - ROG NX Snow Switches |
Software | Windows 11 Pro |
I need help creating a program that takes input from the user, stores it into an array, and then combines everything in the end. Here is the first part of the program, but I do not know what to do next. I may even be going in the wrong direction. But, here it is:
import java.util.Scanner;
public class Gauss
{
public static void main(String[] args)
{
Scanner reader = new Scanner(System.in);
System.out.print("Enter the number of times the loop should run: ");
int num3 = reader.nextInt();
int[] ia = new int[num3];
for (int i = 0; i < ia.length; i++)
{
ia = i;
}
int sum = 0;
for (int i = 0; i < ia.length; i++)
{
sum += ia;
}
System.out.println(sum);
}
}
import java.util.Scanner;
public class Gauss
{
public static void main(String[] args)
{
Scanner reader = new Scanner(System.in);
System.out.print("Enter the number of times the loop should run: ");
int num3 = reader.nextInt();
int[] ia = new int[num3];
for (int i = 0; i < ia.length; i++)
{
ia = i;
}
int sum = 0;
for (int i = 0; i < ia.length; i++)
{
sum += ia;
}
System.out.println(sum);
}
}