It is not working correctly. Say I enter the following numbers: 4 4 3 3 3 5 6 6 the program says:
The largest number is 4
The occurrence count of the largest number is 1
The second largest...
Type: Posts; User: hhman1
It is not working correctly. Say I enter the following numbers: 4 4 3 3 3 5 6 6 the program says:
The largest number is 4
The occurrence count of the largest number is 1
The second largest...
So I tried to assign values and now it prints out that max is the first number I type and that the occurrence is one.
if(number != 0){
if(number > max){
max = number;
...
Max and nextmax both have a value of 0. The variables should be assigned a value in
if(number != 0){
if(number > max){
maxcount = 1;
The if loops should assign values to the four variables all of which print as 0. For some reason they do not.
Oops forgot a part, which I just edited in. And yes it compiles without errors.
So I've changed quite a bit over the past few days and I'm on the verge getting it right. I still have a few problems though. My output is 0 regardless of the integers I put in. I changed the while...
The new values would be:
max =6, count=1
nextMax = 5 count=2
Haha I'm just getting more and more confused. Really wish I had a real life teacher. Here is what I now have but I don't think it makes sense.
import java.util.Scanner;
public class Unit4PT1 {...
What I don't understand is how to assign a value to nextLargest. if(number > max) gives me largest but...
How would I compare the largest variable to the old largest? Here is what I now have
import java.util.Scanner;
public class Unit4PT1 {
public static void main (String [] args){
Scanner in =...
Okay I've got a homework assignment to write a program that reads integers, finds the TWO (2) largest of them, and counts their occurrences. I've managed to get the largest number but can I get any...
Managed to solve my problem :)
I'm just starting out at Java programming so my problem is likely obvious. The program needs to prompt the user to enter an integer and checks whether the number is divisible by 4, 5 and 6, or some...
Just wanted to say hello to the community. I'm currently learning Java programming as a hobby which I hope to expand upon in the coming years. I'm pretty sure I'll be coming here frequently as I...