#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    12
    Rep Power
    0

    Thumbs up C++ washing machine


    design a digitally controlled washing machine that sets the wash temperature to 80degree celcius for cotten clothes 40degree celcius per quick wash and 1000 revolution for rinse and dry only using MV STUDIO 2010 c++ programming
    i need an improvement on this please!

    #include <iostream>
    using name space std;
    void main()
    {
    int tempsensor; //from the temperature sensor console

    int revolcycle; //gotten from the motor console

    char washtype;
    int revolution = revolcycle/timer
    {
    if (washtype = cotton)
    {
    tempsensor = 80;
    cout <<"ready for cotton";
    }
    if (washtype = quickwash)
    {
    tempsensor = 40;
    cout<<" ready for quickwash";
    }
    void rinse (int revolution)
    {
    return 1000;
    }
    void dry (int revolution)
    return 1000;
    }
    }
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    159
    Rep Power
    19
    Do you have a specific problem or question?

    I suggest you start by fixing your compile errors. If you have questions about those errors, post the complete error messages and ask specific questions.

    Also please use code tags when posting code.

    Jim
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    12
    Rep Power
    0

    hi jim


    this is all i could do, please help add more in respect to the question


    #include <iostream>
    using namespace std;
    int main()
    {
    int tempsensor; //from the temperature sensor console

    int revolcycle=1000; //gotten from the motor console
    int timer =1 ;
    char washtype;
    int revolution = revolcycle/timer;
    char cotton;
    char quickwash;

    if (washtype = cotton) //link to a button in the machine through console
    {
    tempsensor = 80;
    cout <<"ready for cotton";
    return (0);
    }
    if (washtype = quickwash)
    {
    tempsensor = 40;
    cout<<"ready for quick wash\n";
    }
    if (revolution = 1000)
    {
    char rinse;
    char dry;

    }
    {

    system ("pause");
    }

    }
  6. #4
  7. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Posts
    4,376
    Rep Power
    1871
    1. Use [code][/code] tags when you post code, so that formatting and indentation are preserved.

    Like so.
    Code:
    #include <iostream>
    using namespace std;
    int main()
    {
      int tempsensor;               //from the temperature sensor console
      int revolcycle = 1000;        //gotten from the motor console
      int timer = 1;
      char washtype;
      int revolution = revolcycle / timer;
      char cotton;
      char quickwash;
    
      if (washtype = cotton)        //link to a button in the machine through console
      {
        tempsensor = 80;
        cout << "ready for cotton";
        return (0);
      }
      if (washtype = quickwash) {
        tempsensor = 40;
        cout << "ready for quick wash\n";
      }
      if (revolution = 1000) {
        char rinse;
        char dry;
      }
      {
        system("pause");
      }
    }
    2. If you don't have GCC, then I suggest you get it (try an IDE like code::blocks which comes pre-packaged with GCC).

    Then you get some rather useful error messages.
    Code:
    $ g++ -W -Wall -Wextra bar.cpp
    bar.cpp: In function ‘int main()’:
    bar.cpp:13:24: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
    bar.cpp:19:27: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
    bar.cpp:23:24: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
    bar.cpp:24:10: warning: unused variable ‘rinse’ [-Wunused-variable]
    bar.cpp:25:10: warning: unused variable ‘dry’ [-Wunused-variable]
    bar.cpp:28:19: error: ‘system’ was not declared in this scope
    One thing you need to understand is the difference between = and ==
    = is assignment
    == is comparison

    Let's say
    Code:
      char cotton = 'C';
      char quickwash = 'Q';
    
      if (washtype == cotton)        //link to a button in the machine through console
    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
  8. #5
  9. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,145
    Rep Power
    2222
    Originally Posted by alaba81
    this is all i could do, please help add more in respect to the question
    What question?

    We won't do your homework for you. We will help you with specific questions that you may have. But first you need to ask a question!

IMN logo majestic logo threadwatch logo seochat tools logo