Tag Archives: help

Help with Java programming! I keep getting “illegal start of expression” error message?

Question by kathy: Help with Java programming! I keep getting “illegal start of expression” error message?
I wrote these lines of code about halfway through my program

if((change-.25)>=.20)
{
System.out.println(” two dimes,”);
System.out.println(“and” + change-.45 + ” pennies”);
}

if(((change-.25)>=.1)&&((change-.25)<.2))
{
System.out.println(" one dime,");
System.out.println("and" + change-.35 + " pennies");
}

When I try to compile I keep getting a message saying that the second line containing if is "illegal start of expression"
I had this line earlier and BlueJ seemed happy with it. Then I added more stuff later in my program and when I went back to compile it didn't like this line. It's happy with all the other "if" statements coming before it. What do you think the problem is? I'm not very good with these computer things :-(

By the way, there's no "..." after the if statement. it's actually just another ")"
I have "change" entered as a float

Best answer:

Answer by deonejuan
IDK… is the variable ‘change’ of type int???

change should be type double or float if your want decimal numbers.

===============
I see it now,

float change = 0f;

if ((change – .25) >= .20f) {
System.out.println(” two dimes,”);
System.out.println(“and ” + (change – .45f) + ” pennies”);
}

the parser in java is confused at the string inside println(). Put your math inside parenthesis.

note the …
float change = 0f;
// this is still a float
change – .25
if (change -.085) == 1.00 { // two terms, one on the right is a double, make it a float by 1.00f

but yoru basic problem is the parenthesis inside the concate strings

Give your answer to this question below!

I’m looking for a Precious Moments waterball of a boy in a gumball machine. No luck on eBay or internet. Help!

Question by Kelly H: I’m looking for a Precious Moments waterball of a boy in a gumball machine. No luck on eBay or internet. Help!
I believe it is called “Count your many blessings.” It plays “Toyland.” The boy is in a gumball machine-shaped waterball with another gumball machine inside next to him. There is a little sign on the inner gumball machine that says “Just one penny.” I need any help I can get. I have tried collector websites and the internet in general, but so far no luck.

Best answer:

Answer by exbuilder
A Yahoo search for “precious moments collectibles” (include the quotation marks) turned up 105,000 results. Just the first two pages of results turned up promising sites. Many of them identify, catalog, price, buy, and sell these items. I am sure that if you do the same search, and spend a little time exploring, you will quickly find the information you seek.

Good luck with your search.

Know better? Leave your own answer in the comments!

Microtype Game part help please?

Question by yusuf s: Microtype Game part help please?
Microtype “Game” part! Help PLEASE?
K. So I was playing Microtype at school and on the game part we have to finish and I couldn’t figure it out.
It was a picture of a penny then an owl saying E=mc2 and then an 11lb of gold thing then a gas needle thing on Full with a plus +ish.
The spaces are _ _ _ _ _ _ _ _ _’ _ _ _ _ _ _ _ _ _ _ _ _
Does anybody know what goes in the blanks

Best answer:

Answer by Is
penny wise pound foolish

Know better? Leave your own answer in the comments!

C++ help program is written just need some help with the loop?

Question by RAYJAY: C++ help program is written just need some help with the loop?
int main ( )
{

InputData();
while(CostOfPurchase != -1)
{
CHANGE();

OutputData();
}
return 0;
}

void InputData()
{
cout<<"Enter cost of purchase : ";
cin>> CostOfPurchase;
cout<

cout<<"Enter amount tendered : ";
cin>> AmountTendered;
cout<

}

void CHANGE()
{
FinalChange= AmountTendered - CostOfPurchase;

(int)dollar= (FinalChange + 0.00001)/1.00;
change = (FinalChange + 0.00001) - dollar;

(int)quarter= change/0.25;
change = change - .25*quarter;

(int)nickel= change/0.05;
change = change - .05 * nickel;

(int)penny = change/0.01;

}

void OutputData()
{

cout<< fixed<

cout<<"The change is $"<< FinalChange <

cout<< dollar<<" dollar"< cout<< quarter<<" quarter"< cout<< nickel<< " nickel"< cout<< penny<< " penny" <

}
The program is finished but I need to throw a loop in hear. Where can I put it. it needs to be
while(CostOfPurchase != -1), where do I throw it in here. I have tried a few spots but just not working, and it is driving me nuts. Any help would be much appreciated. But the program does work just need to throw that loop in hear so when I enter -1 it ends.
Thanks for that comment but that only loops cost of purchase. I am looking for it to loop the whole program, and only stop when I enter -1 in that area

Best answer:

Answer by tpennetta
You need to enter it in InputData() just before the first line. So it should look like this:

void InputData()
{
while (CostOfPurchase != -1)
{
cout<<"Enter cost of purchase : ";
cin>> CostOfPurchase;
cout< }

cout<<"Enter amount tendered : ";
cin>> AmountTendered;
cout<

}

At least that's what it seems like your asking

Bet of Luck!

Add your own answer in the comments!

Cost of pennies Chemistry experiment PLEASE HELP?

Question by Jackie: Cost of pennies Chemistry experiment PLEASE HELP?
I have the mass of the copper, the mass of the zinc, the percent of copper, the percent of zinc in both a pre-1982 penny and a post-1982 penny. I also have the information that the cost of zinc should be .33/lb and the cost of copper should be .36/lb. How do I determine the “Cost of each penny (cents)?”

Best answer:

Answer by m w
lbs alloy / penny x (lbs zinc / lb ore) x ($ / lb zinc) +
lbs alloy / penny x (lbs copper / lb ore) x ($ / lb copper) = $ per penny.

right? if a penny weighs…2.5g…and was 95% Cu and 5% Zn prior to 1982.. then…

2.5g metal x (1 lb / 453.54g) x (5 lbs Zn / 100 lbs metal) x (.33 / lb Zn) +
2.5g metal x (1 lb / 453.54g) x (95 lbs Cu / 100 lbs metal) x (.36 / lb Zn) = .0180 / penny.

similarly.. a post ’82 penny…is 97.5% Zn and 2.5% Cu…

2.5g metal x (1 lb / 453.54g) x (97.5 lbs Zn / 100 lbs metal) x (.33 / lb Zn) +
2.5g metal x (1 lb / 453.54g) x (2.5 lbs Cu / 100 lbs metal) x (.36 / lb Zn) = .0076 / penny.

********
can you guess why it was changed? when the price of copper went up, it became too expensive to make pennies. the metal was more than the penny was worth. right? a penny is worth .01….

****************
do you understand the math?

Give your answer to this question below!

Help with rather simple c program?

Question by a goofier fox: Help with rather simple c program?
I’m having trouble debugging this program. The program is supposed to accept a dollar and change amount from the user and basically find the most “efficient” bill and coin representation of it.

This what I have so far…it will not compile on line 71.

#include
#include

/* Function Prototypes */
void instruct_money(); /* Displays the instructions for the the calculator */
void payment(double total, int *twenty_bills, int *ten_bills, int *five_bills, int *dollars,
int *quarters, int *dimes, int *nickels, int *pennies); /* Calculates amount of each bill and coin*/

int
main(void)
{
double total; /*Input – the user’s total amount of money*/

/*Displays instructions*/
void instruct_money();

/*Prompts the user to enter the amount of money and scans it*/
printf(“Please enter your total amount of money. >> “);
scanf(“%lf”, &total);
if(total < 0)
{
printf("The amount you entered is negative! \n");
printf("The amount of each bill and coin cannot be calculated.\n");
}
else
{
void payment(double total, int *twenty_bills, int *ten_bills, int *five_bills, int *dollars,
int *quarters, int *dimes, int *nickels, int *pennies);

}
}

void
instruct_money()
{
printf("This program calculates the amount of each bill and coin that \n");
printf("you have from the total amount of money that you enter. \n");
printf("Please input a positive amount in numerical form with a decimal \n");
printf("seperating the dollars and cents. \n \n \n");
}

void
payment(double total, int *twenty_bills, int *ten_bills, int *five_bills, int *dollars,
int *quarters, int *dimes, int *nickels, int *pennies)
{
int dollar; /*Local variable - the amount of dollars*/
int cent; /*Local variable - the amount of cents */
double temp1;
double temp2;

/*Separates the dollar amount and cent amount*/
dollar = floor(total);
cent = (total - dollar) * 100;

/*Calculates the amount of each bill*/
*twenty_bills = dollar/20;
temp1 = dollar %20;
*ten_bills = temp1/10;
temp2 = temp1 %10;
*five_bills = temp2/5;
*dollars = temp2%5;

/*Calculates the amount of each coin*/
*quarters = cent/25;
temp1 = cent%25;
*dimes = temp1/10;
temp2 = temp1%10;
*nickels = temp2/5;
*pennies = temp2%5;

/* Prints the results to the user*/
printf("You currently have %d twenty dollar bills, %d ten dollar bills \n" *twenty_bills, *ten_bills);
printf("%d five dollar bills, %d dollar bills, %d quarters, %d dimes \n" *five_bills, *dollars, *quarters, *dimes);
printf("%d nickels, and %d pennies." *nickels, *pennies);

}

Best answer:

Answer by Tyler
uhhhh…. I don’t want to read all that but I will tell you that integer division would be the easiest way to do this. Integer division returns the most that can be evenly divided int a number. You specify to the compiler to do int division by declaring both variables as integers.
int a = 9;
int b = 2;
a / b would equal 4 not 4.5

I know your thinking “what about the change” but that’s easily fixed. Just take the given amount and multiply by 100.

What do you think? Answer below!

help on java program?

Question by tyler r: help on java program?
I need to get the coins from one purse to transfer to the other purse, which already has coins in it. So they would add.

My current code is:

import java.util.*;
public class Purse
{

private static ArrayList coins;

public Purse()
{
coins = new ArrayList();
}

void addCoin(String coinName)
{
coins.add(coinName);
}

public String toString()
{
return coins.toString();
}

public void transfer(Purse other)
{
int i = 0;
while(i < coins.size())
{

coins.addAll(i.coins);
String b = other.coins.add(i);

}
}

public static void main(String[] args)
{
Purse manpurse = new Purse();
manpurse.addCoin("Quarter");
manpurse.addCoin("Dime");
manpurse.addCoin("Penny");
manpurse.addCoin("Nickel");
System.out.println(manpurse);

Collections.reverse(coins);
System.out.println(manpurse);

}

}

My transfer code is currently incorrect and I'm not sure how to fix it, been doing it for a couple days now.

Best answer:

Answer by Chris
Why are you using strings? Just make a Purse class and give it an int variable for coins. The make a method that takes an int and a purse as reference values and subtract the value from one purse and add the same value to the current purse.

Give your answer to this question below!

Can someone help me with this Java code?

Question by JYOTI N: Can someone help me with this Java code?
import java.text.NumberFormat;
import java.util.Scanner;

public class Coins
{

public static void main (String [] args)
{

int quarters;
int dimes;
int nickels;
int pennies;
double totalCoins;

Scanner scan = new Scanner(System.in);

System.out.println(“Enter the number of quarters. “);
quarters = scan.nextInt();

System.out.println(“Enter the number of dimes. “);
dimes = scan.nextInt();

System.out.println(“Enter the number of nickels. “);
nickels = scan.nextInt();

System.out.println(“Enter the number of pennies. “);
pennies = scan.nextInt();

quarters = quarters *= 0.25;
dimes = dimes *= 0.10;
nickels = nickels *= 0.05;
pennies = pennies *= 0.01;

NumberFormat fmt = NumberFormat.getCurrencyInstance();

totalCoins = quarters + dimes + nickels + pennies;

System.out.println(“The total amount of money is ” + fmt.format(totalCoins));

}

}

Ok, so it runs, but the answer does not show up right. Like it rounds it so much. i dont want that. I want the answer to 2 decimal places.

Best answer:

Answer by Ben
First of all, quarters = quarters *= .25 is redundant. The whole point in the syntax “quarters *= 0.25″ is to do the multiplication and the assignment. The reason it’s rounding is because quarters, nickels, dimes, and pennies are declared as an int- they are incapable of having decimal values. Java does this by truncating the value so that 3 * .25 = 0 instead of 0.75. Just use doubles instead of ints and it should work fine.

Give your answer to this question below!

Programming help.. C++ Change making?

Question by thesandstereo: Programming help.. C++ Change making?
#include
using namespace std;
int main()
{
int dollars,quarters,dimes,nickels,pennies,amount_due,amount_due_value,dollar_value,quarter_value,dime_value,nickel_value,penny_value,dollars_due,quarters_due,dimes_due,nickels_due,pennies_due;
cout << "Please enter amount_due:";
cin >> amount_due;
amount_due_value = amount_due*100;
cout << "Please enter the amount of money you intend to use:\n"
<< "Please enter the number of dollars:";
cin >> dollars;
dollar_value = dollars*100;
cout << "Please enter the number of quarters";
cin >> quarters;
quarter_value = quarters*25;
cout << "Please enter the number of dimes";
cin >> dimes;
dime_value = dimes*10;
cout << "Please enter the number of nickels";
cin >> nickels;
nickel_value = nickels*5;
cout << "Please enter the number of pennies";
cin >> pennies;
penny_value = pennies*1;
dollars_due = amount_due_value – dollar_value;
quarters_due = (amount_due_value-dollars_due)/quarter_value;
dimes_due = (amount_due_value-dollars_due-quarter_value)/dime_value;
nickels_due = (amount_due_value-dollars_due-quarters_due-dime_value)/nickel_value;
pennies_due = (amount_due_value-dollars_due-quarters_due-dime_value-nickels_due)/penny_value;
cout << "Your change consists of:" << dollars_due << "dollars" << quarters_due << "quarters" << dimes_due << "dimes" << nickels_due << "nickels" << pennies_due << "pennies." < return 0;
Point of the program is input purchase amount, how much you have to spend, and then dispense change. I have spent hours trying to get this to work... either I get modulus errors or the program runs incorrectly.. if there is a way to get this to work, not to mention make it less bulky that would be great, help much apperciated.
No compiling errors as typed, but it is not working right.

Best answer:

Answer by BigRez
What’s the problem? (You want us to compile this and debug it for you?)

***Update***
OK – I’m guessing at what it’s supposed to do. I suspect you’ll enter an amount due and an amount paid, like 33.58 (due) and 50.00 paid, and the program should spit out something like:
Change due: .42 paid as
1 Ten dollar bill,
1 Five dollar bill,
1 One dollar bill,
1 Quarter,
1 Dime,
1 Nickle,
2 pennies.

If this is correct, then you can do it using the following logic:

1) Get the amount due and amount paid (You alreadu have this as amount_due and dollars)
2) These should both be float values as you’ll want to know fraction values.

3) Once you get the input, you need to validate it. Make sure the amount due is > 0.01 and that the amount paid is > amount due.

4) Create two arrays to hold your “change drawer” items. This would be something like:
char changeDesc[9][30] = {
“One Hundred Dollar Bill”,”Fifty Dollar Bill”,”Twenty Dollar Bill”, <"Dime","Nickle","Pennies"};
float changeAmt[9]={10000,5000,2000, ... 10, 5, 1};
//Note: above values are 100* actual value to remove decimal.

5) Calculate the amount due: changeDue=(int)(dollars-amount_due*100);

7) You'll then have a loop which will compute a reducing balance based on the number of change items given.
Each time through, you'll compare the changeDue value to that in the changeAmt[position]. If it's smaller than the changeAmt[position] value, add one to position. If not, then print out 1 changeDesc[position] value andsubtract changeAmt[position] from the change_due.

Now the above will print multiple lines for each time. For example, if you should get three one dollar bills, it'll print One Dollar Bill three times. You can add code to total each item up and print the total, but get the first part working before you worry about that. Post a new question with your changed source once you're ready for review.

(Or - email me at mdr1119 @ sbcglobal.net and I'll respond.)

Know better? Leave your own answer in the comments!

QuickBooks: 22 Essential Tips to Help You Use it Wisely

QuickBooks: 22 Essential Tips to Help You Use it Wisely
Tap into the field-tested and certified expertise of Scott Gregory, QuickBooks Specialist. Download his tips, secrets and insight on using QuickBooks wisely today! Scott has helped hundreds of businesses “figure out” QuickBooks. Let him help you too!
QuickBooks: 22 Essential Tips to Help You Use it Wisely

Wise-Up Workouts: How to Re-Construct Your Body in 30 Days or Less
Finally, a smart, efficient workout that solves the weight loss and fat burning problems from the inside-out. Wise-Up workouts was developed to guarantee results for the honest consumer. Its a scientifically proven bodyweight interval rhythmic workout.
Wise-Up Workouts: How to Re-Construct Your Body in 30 Days or Less

NWT Vera Bradley Frill Penny Wise Wallet New Blue Lagoon Folkloric
US $18.00
End Date: Monday May-28-2012 19:13:39 PDT
Buy It Now for only: US $18.00
Buy it now | Add to watch list
Grip Studios Penny Wise Custom Guitar Grip Pennywise - NEW
US $35.95
End Date: Tuesday May-29-2012 14:28:54 PDT
Buy It Now for only: US $35.95
Buy it now | Add to watch list
Page 1 of 3123