Question: keep getting decimal answers for the change and it need to be whole numbers. import java.util.Scanner ; public class pirates { static final

keep getting decimal answers for    the change and it need to be whole numbers. 

 


import java.util.Scanner ;
public class pirates
{

static final double Genuine_PieceofEight = 8;
static final double PirateHat = 32;
static final double EyePatch = 1;
static final double Sword= 20;
static final double TreasureMap=100;
static final double Teeshirt= 150;

static int numberGenuinePieceofEight;
static int numberPirateHat;
static int numberEyePatch;
static int numberSword;
static int numberTreasureMap;
static int numberTeeshirt;


public static void main(String[] args) {

double GenuinePieceofEight =0;


  Scanner input = new Scanner(System.in);
  System.out.println("How many Pieces of Eight do you want?");
  String numberShirts = input.nextLine();

  System.out.println("How many Pirate Hats?");
  String numberChips = input.nextLine();

  System.out.println("How many eye patches?");
    numberEyePatch = input.nextInt();

  System.out.println("How many swords do you need?");
  String numberSwords=input.nextLine();

  System.out.println("How many treasure maps will you need?");
    numberTreasureMap=input.nextInt();

  System.out.println("How many tee shirts will you need?");
    numberTeeshirt= input.nextInt();

 


  GenuinePieceofEight = GenuinePieceofEight * numberGenuinePieceofEight;


 double  Piratehat  = PirateHat*numberPirateHat;

 double Eyepatch = EyePatch*numberEyePatch;

 double sword=   Sword*numberSword;

 double treasureMap=TreasureMap*numberTreasureMap;

 double teeshirt=Teeshirt*numberTeeshirt;

 double finalTotal = GenuinePieceofEight + Piratehat + Eyepatch+sword+treasureMap+teeshirt;;

  System.out.println("Your total is: " + finalTotal +"BITS");

{
System.out.println("How many Bits was your items?");
       int inputBits = input.nextInt();
     
       System.out.println("How man gold doubloons have ye got?");
       int inputDoubloons = input.nextInt();

       // Lable exchanges
       final int DOUBLOON = 128;
       final int PISTOLE = 32;
       final int Pe = 8;
       final int BIT = 1;
       // Declare they are numbers COUNT of coins
       double numBits, numPistole, numPe, numDoubloon;
       // Calculations % is remander (thank you textbook)
       // value of coins and count
       int userdblvalue;
       userdblvalue = inputDoubloons * DOUBLOON;
       double change= finalTotal - userdblvalue;
       change = userdblvalue - inputBits;
       numDoubloon = change / DOUBLOON; // count of doubloons
       change = change % DOUBLOON; // change left
       numPistole = change / PISTOLE; // count of pistole
       change = change % PISTOLE; // change left
       numPe = change / Pe;// count of Pe
       change = change % Pe;// change
       numBits = change; // number of bits

       // Give change equivilant.
       System.out.println("Yer change is:");

       // else if statements to print correct
       if (numBits == 1) {

           System.out.println(numBits + BIT);
       }

       
       else if (numBits == 0) {
           System.out.println();
       } else {
           System.out.println(numBits + " Bits");
       }

       if (numPe == 1) {
           System.out.println(numPe + "Piece Of Eight");
       } else if (numPe == 0) {
           System.out.println();
       } else {
           System.out.println(numPe + "Pieces Of Eight");
       }

       if (numPistole == 1) {
           System.out.println(numPistole + "Pistole");
       } else if (numPistole == 0) {
           System.out.println();
       } else {
           System.out.println(numPistole + " Pistoles");
       }

       if (numDoubloon == 1) {
           System.out.println(numDoubloon + "Doubloon");
       } else if (numDoubloon == 0) {
           System.out.println();
       } else {
           System.out.println(numPe + "Doubloons");
       }
       // Print out last line

       System.out.println("Now shove off before I make ye walk the plank!");
   }
}
}

 

 

 

BlueJ: Terminal Window - Welcome Options How many Bits was your items?

BlueJ: Terminal Window - Welcome Options How many Bits was your items? 650 How man gold doubloons have ye got? 120 Yer change is: 6.0 Bits 2.75Pieces Of Eight 3.6875 Pistoles 2.75Doubloons Now shove off before I make ye walk the plank! How many Pieces of Eight do you want? 0 How many Pirate Hats? 1 How many eye patches? 3 How many swords do you need? How many treasure maps will you need? 0 How many tee shirts will you need? 2 Your total is: 303.0BITS How many Bits was your items? 303 How man gold doubloons have ye got? 5 Yer change is: 2.0 2.125Pieces Of Eight 2.53125 Pistoles 2.125Doubloons Now shove off before I make ye walk the plank! Can only enter input while your programming is running W I X 4:12 PM 3/18/2022

Step by Step Solution

3.58 Rating (155 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

import javautilScanner public class Pirates static final double GenuinePieceofEight 8 static final double PirateHat 32 static final double EyePatch 1 ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!