Question

THIS IS MY CODE ALL I NEED IS THE SECTIONS TO BE FILLED IN AND CODE...

THIS IS MY CODE ALL I NEED IS THE SECTIONS TO BE FILLED IN AND CODE SHOULD RUN.

FILL IN THE CODE PLEASE.

package p02;

import static java.lang.System.*;
import java.io.*;
import java.util.*;

public class P02 {
  
public static Vector<Double> wallet=new Vector<Double>();
  
public static void addMoneyToWallet(){
  
}
  
public static void removeMoneyFromWallet(){
  
}
  
public static void displayMoneyInWallet(){
  
}
  
public static void emptyWallet(){
  
}

  
public static void main(String[] args){
int choice=0;
String menu="Wallet Application:\n\n" +
"1) Add Money to Wallet\n" +
"2) Remove Money from Wallet\n" +
"3) Display Money in Wallet\n" +
"4) Empty Wallet\n" +
"5) Exit\n" +   
"Please enter a selection->";
do {
choice=HelperClass.getIntegerInput(menu);
switch(choice){
case 1:
addMoneyToWallet();
break;
case 2:
removeMoneyFromWallet();
break;
case 3:
displayMoneyInWallet();
break;
case 4:
emptyWallet();
break;
case 5:
out.println("Okay, goodbye!!!");
break;
default:
out.println("That is not a valid choice.../nPlease try again!!!\n\n");
break;
}
}while(choice!=5);   
}
  
}

0 0
Add a comment Improve this question Transcribed image text
Answer #1

import static java.lang.System.out;

import java.util.Scanner;
import java.util.Vector;

public class P02 {

   public static Vector<Double> wallet = new Vector<Double>();
   static Scanner sc = new Scanner(System.in);
   public static void addMoneyToWallet() {
       // reading and adding money to wallet
       System.out.println("Enter money to add into wallet");
       Double m=sc.nextDouble();
       wallet.addElement(m);
   }

   public static void removeMoneyFromWallet() {
       // reading and removing money from wallet
       System.out.println("Enter money to remove from wallet");
       Double m=sc.nextDouble();
       wallet.removeElement(m);
   }

   public static void displayMoneyInWallet() {
       // displaying the money from wallet
       System.out.println(wallet);
   }

   public static void emptyWallet() {
       // Clearing the wallet
       wallet.clear();
   }

   public static void main(String[] args) {
       int choice = 0;
       String menu = "Wallet Application:\n\n" + "1) Add Money to Wallet\n" + "2) Remove Money from Wallet\n"
               + "3) Display Money in Wallet\n" + "4) Empty Wallet\n" + "5) Exit\n" + "Please enter a selection->";
       do {
           choice = HelperClass.getIntegerInput(menu);
           switch (choice) {
           case 1:
               addMoneyToWallet();
               break;
           case 2:
               removeMoneyFromWallet();
               break;
           case 3:
               displayMoneyInWallet();
               break;
           case 4:
               emptyWallet();
               break;
           case 5:
               out.println("Okay, goodbye!!!");
               break;
           default:
               out.println("That is not a valid choice.../nPlease try again!!!\n\n");
               break;
           }
       } while (choice != 5);
   }

}

Add a comment
Know the answer?
Add Answer to:
THIS IS MY CODE ALL I NEED IS THE SECTIONS TO BE FILLED IN AND CODE...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • For Project 02 you’re going to take starter code I’m providing (See in BlackBoard under Projects->Project...

    For Project 02 you’re going to take starter code I’m providing (See in BlackBoard under Projects->Project 02). The zip file contains a P02.java, a HelperClass.java, and an enumeration under Money.java. The only coding you’ll do will be in P02.java. I’ve already provided you with the menu and switch as well as all the methods you’ll need stubbed out. Your assignment is to take the program and complete it without adding any more methods but merely adding code to those stubbed...

  • Help! Not sure how to create this java program to run efficiently. Current code and assignment...

    Help! Not sure how to create this java program to run efficiently. Current code and assignment attached. Assignment :Write a class Movies.java that reads in a movie list file (movies.txt). The file must contain the following fields: name, genre, and time. Provide the user with the options to sort on each field. Allow the user to continue to sort the list until they enter the exit option. ---------------------------------------------------------- import java.util.*; import java.io.*; public class Movies { String movieTitle; String movieGenre;...

  • Java Assignment Calculator with methods. My code appears below what I need to correct. What I...

    Java Assignment Calculator with methods. My code appears below what I need to correct. What I need to correct is if the user attempts to divide a number by 0, the divide() method is supposed to return Double.NaN, but your divide() method doesn't do this. Instead it does this:     public static double divide(double operand1, double operand2) {         return operand1 / operand2;     } The random method is supposed to return a double within a lower limit and...

  • Please write where its written write your code here!! please use java for the code! please...

    Please write where its written write your code here!! please use java for the code! please use the given code and I will rate thanks Magic index in an array a[1..n] is defined to be an index such that a[ i ] = i. Given an array of integers, write a recursive method to find the first magic index from left to right. If one exists in the given array, return the index number i, otherwise return -1. Here are...

  • Type, Compile, Run all syntactically complete or mostly complete example code .You may need to change...

    Type, Compile, Run all syntactically complete or mostly complete example code .You may need to change some syntax to make them compile and run import java.io.*; import java.lang.*; import java.util.*; class MyThreadExampleMutex{ public static void main(String[] args) { new HelloThread (1). start (); new HelloThread (2). start (); new HelloThread (3). start (); System.out.print("Global.buffer Content = "); for (int i = 0; i < 9; i++) { System.out.print(Global.buffer[i] + "; "); }} } class Global { public static int[] buffer...

  • Need Help ASAP!! Below is my code and i am getting error in (public interface stack)...

    Need Help ASAP!! Below is my code and i am getting error in (public interface stack) and in StackImplementation class. Please help me fix it. Please provide a solution so i can fix the error. thank you.... package mazeGame; import java.io.*; import java.util.*; public class mazeGame {    static String[][]maze;    public static void main(String[] args)    {    maze=new String[30][30];    maze=fillArray("mazefile.txt");    }    public static String[][]fillArray(String file)    {    maze = new String[30][30];       try{...

  • Below I have my 3 files. I am trying to make a dog array that aggerates...

    Below I have my 3 files. I am trying to make a dog array that aggerates with the human array. I want the users to be able to name the dogs and display the dog array but it isn't working. //Main File import java.util.*; import java.util.Scanner; public class Main {    public static void main(String[] args)    {    System.out.print("There are 5 humans.\n");    array();       }    public static String[] array()    {       //Let the user...

  • I need help with adding comments to my code and I need a uml diagram for...

    I need help with adding comments to my code and I need a uml diagram for it. PLs help.... Zipcodeproject.java package zipcodesproject; import java.util.Scanner; import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; public class Zipcodesproject { /** * @param args the command line arguments */ public static void main(String[] args) { Scanner input=new Scanner(System.in); BufferedReader reader; int code; String state,town; ziplist listOFCodes=new ziplist(); try { reader = new BufferedReader(new FileReader("C:UsersJayDesktopzipcodes.txt")); String line = reader.readLine(); while (line != null) { code=Integer.parseInt(line); line =...

  • I need the following java code commented import java.util.Scanner; public class Main { public static void...

    I need the following java code commented import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner input = new Scanner (System.in); int productNo=0; double product1; double product2; double product3; double product4; double product5; int quantity; double totalsales=0; while(productNo !=0) System.out.println("Enter Product Number 1-5"); productNo=input.nextInt(); System.out.println("Enter Quantity Sold"); quantity=input.nextInt(); switch (productNo) { case 1: product1=1.00; totalsales+=(1.00*quantity); break; case 2: product2=2.00; totalsales+=(2.00*quantity); break; case 3: product3=6.00; totalsales+=(6.00*quantity); break; case 4: product4=23.00; totalsales+=(23.00*quantity); break; case 5: product5=17.00; totalsales+=(17.00*quantity); break;...

  • I cannot submit my entire project due to the word count limit. I think my project...

    I cannot submit my entire project due to the word count limit. I think my project looks ok, but my recipe box class and recipe test class is running errors and it may have something to do with the menu portion of the recipe box. Please take a look: "You will create a program that will help you manage a collection of recipes. You will implement three classes: one for the main recipe items, one for the ingredients that are...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT