Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9244747
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:06:38+00:00 2026-06-18T09:06:38+00:00

Write a program that allows a user to enter a number of values, the

  • 0

Write a program that allows a user to enter a number of values, the program should then convert the values entered in pounds (GBP) into a number of different currencies. The menu should look something like this:

  1. Enter values and type -1 to stop
  2. Euros
  3. Dollars
  4. Yen
  5. Rupees
  6. Exit

When 2, 3, 4 or 5 are selected the program should display each value entered in both the original pounds and the converted currency, along with a total of all numbers and converted total.

public class Money {
    public static void main(String[] args) {
        System.out.println("Enter values and type -1 to stop"); 
        System.out.println("'1' = Euros"); 
        System.out.println("'2' = Dollars"); 
        System.out.println("'3' = Yen"); 
        System.out.println("'4' = Rupees"); 
        System.out.println("'5' = Exit"); 

        int count=0;
        String exit = "-1", euro="E";

        Scanner scan = new Scanner(System.in);

        System.out.println();
        System.out.print("Convert to: ");

        while (!scan.hasNext("[E, D, Y, R, X]+")) {
            System.out.print("Invalid value, enter Surname again: ");
            scan.next();
        }

        String exTo = scan.next();

        ArrayList<String> num = new ArrayList<String>();

        while (true) {
            count++;
            System.out.print("|| Enter values "+count+" in (P)Pounds : ");

            while (!scan.hasNextDouble()) {
                System.out.print("Invalid value, try again: ");
                scan.next();
            }
            num.add(scan.next());

            if(num.contains(exit)){
                String ar[]=num.toArray(new String[num.size()]);
                ar=num.toArray(ar);

                System.out.println("Result: "+ num);

                scan.close();
                break;
            }
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T09:06:40+00:00Added an answer on June 18, 2026 at 9:06 am

    try this :

    import java.util.*;
    class Money {
        public static void main(String[] args) {
            System.out.println("Enter values and type -1 to stop"); 
            System.out.println("'1' = Euros"); 
            System.out.println("'2' = Dollars"); 
            System.out.println("'3' = Yen"); 
            System.out.println("'4' = Rupees"); 
            System.out.println("'5' = Exit"); 
        int count=0;
        String exit = "-1", euro="E";
    
        Scanner scan = new Scanner(System.in);
    
        System.out.println();
        System.out.print("Convert to: ");
    
        while (!scan.hasNext("[E, D, Y, R, X]+")) {
            System.out.print("Invalid value, enter Surname again: ");
            scan.next();
        }
    
        String exTo = scan.next();
    
        ArrayList<String> num = new ArrayList<String>();
    
        while (true) {
            count++;
            System.out.print("|| Enter values "+count+" in (P)Pounds : ");
    
            while (!scan.hasNextDouble()) {
                System.out.print("Invalid value, try again: ");
                scan.next();
            }
            num.add(scan.next());
    
            if(num.contains(exit)){
                for(int i=0;i<num.size();i++){
                num.set(i,Integer.toString((Integer.parseInt(num.get(i))*2)));
                }
                System.out.println("Result: "+ num);
    
                scan.close();
                break;
            }
        }
    }
    }
    

    to remove the last input (-1)

    add this line before print num.remove("-1");

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an assignment to Write a C program that allows a user to
I'd like to write a python program that allows the user to key an
I want to write a program that allows user to select one SQL Server
I am trying to write a program that allows a binary to be run,
I'm needing to write a program (C#) that will allow the user to create
I'm trying to write a program that scans in values from the console and
I'm writing a program that allows the user to create a username and password.
I need to write a simple Java GUI application that, basically, allows the user
I have a Java program which has a number options it allows the user
I'm doing a small program an addressbook that allows the user to: add contact,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.