Page 3 of 3 FirstFirst 123
Results 21 to 29 of 29

Thread: Need Help With C++ Programming

  1. #21
    Join Date
    Jan 2009
    Posts
    2,404
    Rep Power
    0

    Default

    Quote Originally Posted by mobile_fan_2k5 View Post
    Don't take this for a habit any help after this will be on the terms of you showing something workable then ill help, when i have the time. The program easy took me 10 minutes...
    Code:
    // POS.cpp : Defines the entry point for the console application.
    //
    
    #include "stdafx.h"
    #include<iostream>
    #include <iomanip>
    using namespace std;
    class Point_of_sale
    {
    public:
    Point_of_sale(); //This is a constructor
    void menu();//function to display options
    void processData();//process data
    void display(int,int,double);//display data in an ordered manner
    private:
    int productnumber;
    double retailPrice;
    int productQuantity;
    };
    Point_of_sale::Point_of_sale()//initializing variables in constructor and making them available for other functions to use throughtout code
    {
    productnumber=0;
    retailPrice=0.0;
    productQuantity=0;
    }
    void Point_of_sale::menu()
    {
    cout<<"1-Product 1\n";
    cout<<"2-Product 2\n";
    cout<<"3-Product 3\n";
    cout<<"4-Product 4\n";
    cout<<"5-Product 5\n";
    cout<<"-------------------\n";
    }
    void Point_of_sale::processData()
    {
    do//used for post testing the loop
    {
    menu();
    cin>>productnumber;
    switch(productnumber)
    {
    case 1:
    cout<<"Enter Quantity:";
    cin>>productQuantity;
    retailPrice=static_cast<double>((productQuantity *2.98) + (productQuantity *2.98+0.1625));
    break;//used to break out of a case
    case 2:
    cout<<"Enter Quantity:";
    cin>>productQuantity;
    retailPrice=static_cast<double>((productQuantity *4.50) + (productQuantity  *4.50+0.1625));
    break;
    case 3:
    cout<<"Enter Quantity:";
    cin>>productQuantity;
    retailPrice=static_cast<double>((productQuantity *9.98) + (productQuantity  *4.50+0.1625));
    break;
    case 4:
    cout<<"Enter Quantity:";
    cin>>productQuantity;
    retailPrice=static_cast<double>((productQuantity *4.49) + (productQuantity  *4.50+0.1625));
    break;
    case 5:
    cout<<"Enter Quantity:";
    cin>>productQuantity;
    retailPrice=static_cast<double>((productQuantity *6.87) + (productQuantity  *4.50+0.1625));
    break;
    }
    system("cls");
    display(productnumber,productQuantity,retailPrice);
    cout<<"----------------------------\n";
    }while(productnumber != -1);
    
    }
    void Point_of_sale::display(int val1,int val3,double val2)
    {
    
    	cout<<"------------RECEIPT--------------\n";
    	cout<<"Product : "<<val1<<endl;
    	cout<<"Quantity : "<<val3<<endl;
    	cout<<"Total Price $: "<<fixed<<setprecision(2)<<val2<<endl;
    
    }
    int main()
    {
    	Point_of_sale myapp;
    	myapp.processData();
    	return 0;
    }
    Dude, you're not helping. You didn't explain anything. You're just giving him the answer. That might get him good grades for assignments, but it doesn't help him for classwork and exams. I know how fun it can be to write programs and show your skills. If you're going to do this, at least accompany it with verbose explanations of what you're doing and how you got what you got. Sheesh .

    Hmm. If you think this is so easy and need a challenge, why don't you write a compiler/interpreter and/or create a new programming language? I did .
    Rooted OnePlus 2 64GB Ed, Android 5.1.1 OxygenOS ; on teifin' AT&T's network; Rooted ASUS Transformer TF101 w/ dock, Android 5.1 KatKiss; Laptop: ASUS X550C, 2.0GHzx2, 8GB, 512GB SSD, Kubuntu 15.10;
    Facebook page: Skeleville Technology Solutions

  2. #22
    Join Date
    Dec 2005
    Posts
    1,951
    Rep Power
    0

    Default

    Quote Originally Posted by Skele Drew View Post
    Dude, you're not helping. You didn't explain anything. You're just giving him the answer. That might get him good grades for assignments, but it doesn't help him for classwork and exams. I know how fun it can be to write programs and show your skills. If you're going to do this, at least accompany it with verbose explanations of what you're doing and how you got what you got. Sheesh .

    Hmm. If you think this is so easy and need a challenge, why don't you write a compiler/interpreter and/or create a new programming language? I did .
    i know im not helping him to understand but If i were to explain this code online it will take a while. That's why i said im not writing anymore.
    A NCU you going or use to go..
    Compiler design and interpetation... me hear seh that hard.
    Pc= Hp dv6t

  3. #23
    Yung_Jah Guest

    Default

    Easy to you....cuz you know the basic. And like I said...I need help understanding it. So you typing that, I would rather you explaining to me why you put this there or here. My problem is...to know what to put under main, public and private. You get me. Once I get a clear understanding of that, I am set.

    I can understand that what goes under main, is the outcome of what the question is asking for. So its all about coordination or linking with details from location A to location B.


    I can understand it will take a while to explain online....but if you can find materials to back up what you type....then you can send that link. Still feeling like a dummy!!!!!!!!!!!
    Last edited by Yung_Jah; Sep 28, 2010 at 11:00 PM.

  4. #24
    Join Date
    Jan 2009
    Posts
    2,404
    Rep Power
    0

    Default

    Well, in a nutshell, main is the first function/method that's executed when a program is run, so EVERY application MUST have it, and all other methods are called from it directly or indirectly. Methods declared as public can be called by other methods that are outside the class it belongs to while private is the opposite of public: only other methods found in the class itself can access it. the same applies to private/public fields/variables...
    Rooted OnePlus 2 64GB Ed, Android 5.1.1 OxygenOS ; on teifin' AT&T's network; Rooted ASUS Transformer TF101 w/ dock, Android 5.1 KatKiss; Laptop: ASUS X550C, 2.0GHzx2, 8GB, 512GB SSD, Kubuntu 15.10;
    Facebook page: Skeleville Technology Solutions

  5. #25
    Yung_Jah Guest

    Default

    Yeah....telling me the purpose of main, private and public wont help me. I still need to know what exactly or how one would know what details to add. So telling me what is outside of class or inside...I am clueless as to what you are talking about.

  6. #26
    Yung_Jah Guest

    Default

    Quote Originally Posted by mobile_fan_2k5 View Post
    i know im not helping him to understand but If i were to explain this code online it will take a while. That's why i said im not writing anymore.

    Compiler design and interpetation... me hear seh that hard.
    You could still assist me...once you break it down in a way that I'd be able to understand. So depending on the problem...just to point me to how I should structure something. I do understand what a question is asking for but its how to code it, thats my problem.

  7. #27
    Yung_Jah Guest

    Default

    I am really SUCK at Programming....not even reading can help me...its like hating math. Got this problem to do and I submitted NONSENSE

    A company pays its employees as: managers (who receive a fixed weekly salary); hourly workers (who receive a fixed hourly wage for up to the first 40 hours they work and "time-and-a-half"1.5 times their hourly wage for overtime hours worked); commission workers (who receive $250 plus 5.7 percent of their gross weekly sales); or pieceworkers (who receive a fixed amount of money per item for each of the items they produce ). Create a class with member functions that will calculate each employee type salary. Allowing each function to accept as argument the data they need to calculate the salary. Ask the user to enter the relevant data in main. Each type of employee has its own pay code: Managers have code 1, hourly workers have code 2, commission workers have code 3 and pieceworkers have code 4. Use a simple if statements to initiate your calculate member functions according to that employee's paycode, then prompt the user (i.e., the payroll clerk) to enter the appropriate facts your program needs to calculate each employee's pay according to that employee's paycode.

  8. #28
    Join Date
    Nov 2002
    Posts
    5,713
    Rep Power
    0

    Default

    Quote Originally Posted by Yung_Jah View Post
    I am really SUCK at Programming....not even reading can help me...its like hating math.
    When I started out with BASIC and Java I kept telling myself that I couldn't do it, and how much I didn't like programming, and it showed because I failed. I couldn't even write HTML properly. But when I started spending my hard earn money, I had to change my perception. My point is this, you suck at programming because you keep telling yourself that you can't do it. Programming is all about logical thinking. Until you change your perception you will always suck.

    The problem you posted is very simple, you can't get any simpler than using if/else statements. Here's my advise, sit down and try and pencil out the thing. I find that the hardest part of programming if deciding how you are going to do something (logics), once you work out that the coding will be a piece of cake.
    .:] ^ [:.
    .:] Game IDs: xfire_ropy | BC:BC2_ropy | BC: 2142_ropy29 | BF3_ | steam_ropy09 | LoL_ropy09 | Origin_ropy29 [:.

  9. #29
    Yung_Jah Guest

    Default

    You see, it looks easy to me as well....but problem is...how to write it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •