Thread: Conversion between currency systems

  1. #1
    Registered User
    Join Date
    Feb 2012
    Posts
    1

    Conversion between currency systems

    this is a program i have to write, and im stuck and its due tomorrow at 9 am. heres the assignment description and what i have so far.

    ITCS-2530 Assign #1 - consists of two programs:


    Prog 1A - 20 points


    In the heyday of the British Empire, Great Britain used a monetary system based on pounds, shillings, and pence. There were 20 shillings to a pound, and 12 pence to a shilling. The notation for this old system used the pound sign, £, and two decimal points, so that for example, £5.2.8 meant 5 pounds, 2 shillings, and 8 pence. (Pence is pural for penny).) The new monetary system, introduced in the 1950s, consists only of pounds and pence, with 100 pence to a pound (like U.S. dollars and cents). We'll call this new system decimal pounds. Thus 5.2.8 in old notation is 5.13 in decimal pounds (actually 5.133333). Write a program to convert the old pounds-shillings-pence format to decimal pounds. An example of user's interaction is as follows: [call it I/O Figure #1A for the specs.]


    Enter pounds: 7
    Enter shillings: 17
    Enter pence: 9


    Result in Decimal pounds = £7.89






    Code:
    #include <iostream>
    
    
    using namespace std;
     
    int pounds;
    int shillings;
    int pence;
    double decimalpounds;
    float totalpence
    
    
    
    
    int main() 
    { 
    
    
        cout << "enter number of pounds";
         cin >> pounds;
         
         cout << "enter number of shillings";
         cin >> shillings;
         
         cout << "enter number if pence";
         cin >> shillings
         
         
         totalpence = pounds*240 + shilling*12 + pence
         
         decimalpounds = totalpence
         
         cout << decimalpounds
           
         return 0;
    }

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    What are you stuck on?

    By the way, avoid telling people that you need to get something done by a specific deadline. Some may deliberately answer you only once the deadline is past. After all, the deadline is your problem, not ours.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    So apart from a bunch of missing ; to make it compile, what's your question about your code?

    What do you see when you run it, and how is it wrong?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    I should do something with the title....
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how to do this currency conversion
    By rashid in forum C Programming
    Replies: 2
    Last Post: 02-22-2010, 10:41 PM
  2. Currency Conversion problem
    By Rich Whitehead in forum C Programming
    Replies: 2
    Last Post: 09-17-2007, 12:40 PM
  3. Currency Conversion
    By roadrunnr70 in forum C Programming
    Replies: 8
    Last Post: 12-16-2004, 03:47 PM
  4. Currency Conversion Program
    By Dangerous_Dave in forum C Programming
    Replies: 2
    Last Post: 11-11-2003, 08:54 PM
  5. Currency Conversion Program
    By kgraw21 in forum C Programming
    Replies: 5
    Last Post: 04-19-2002, 08:39 AM