ok, so i have a problem to do in java that i just can't seem to figure out. here is the problem: Write a Java program that prompts the user for how many individuals they will be entering.
Then program will then prompts for each individuals name and account balance. The output of
the program will be the person with the highest account balance (name and balance) and the
lowest account balance (name and balance). All output should be to 2 decimal places.

i dont have a problem with formatting the output or anything i just cant seem to figure this out.
Here's my code:

import java.util.*;

public class Problem2
{
    public static void main(String args[])
        {
            double dblCount = 0;
            double dblBalance = 0;

        Scanner sc = new Scanner(System.in);
            System.out.print("How many Balances will you be entering?: ");
            double dblNumber = sc.nextDouble();

        do
        {
        dblCount = dblCount + 1;    
        System.out.print("Enter a Name: ");
        String strName = sc.next();


        System.out.print("Enter a Balance: ");
        double dblInput = sc.nextDouble();

        if(dblInput > dblInput)
        { 
            dblBalance = dblInput;
        }



    }
    while(dblNumber >= dblCount);
    System.out.println(dblBalance);

        }
}

i'm stuck. If sombody could just point me in the right direction that would be great.
Thanks

Edited 3 Years Ago by mike_2000_17: Fixed formatting

Look at this:

if(dblInput > dblInput)

May be you mean

if(dblInput > dblBalance)

Hope it helps.

dblcount should be an int
dblnumber should also be an int

you want to declare strname as an array outside the loop
also you want to declare dbl balance as an array too

ok, so i have a problem to do in java that i just can't seem to figure out. here is the problem: Write a Java program that prompts the user for how many individuals they will be entering.
Then program will then prompts for each individuals name and account balance. The output of
the program will be the person with the highest account balance (name and balance) and the
lowest account balance (name and balance). All output should be to 2 decimal places.

i dont have a problem with formatting the output or anything i just cant seem to figure this out.
Here's my code:

import java.util.*;

public class Problem2
{
    public static void main(String args[])
        {
            double dblCount = 0;
            double dblBalance = 0;
          
        Scanner sc = new Scanner(System.in);
            System.out.print("How many Balances will you be entering?: ");
            double dblNumber = sc.nextDouble();
            
        do
        {
        dblCount = dblCount + 1;    
        System.out.print("Enter a Name: ");
        String strName = sc.next();
       
        
        System.out.print("Enter a Balance: ");
        double dblInput = sc.nextDouble();
         
        if(dblInput > dblInput)
        { 
            dblBalance = dblInput;
        }
        
        
        
    }
    while(dblNumber >= dblCount);
    System.out.println(dblBalance);
        
        }
}

i'm stuck. If sombody could just point me in the right direction that would be great.
Thanks

This article has been dead for over six months. Start a new discussion instead.