Create a console-based application that computes the price of a desk and whose main() method calls four other methods

a method to accept the number of drawers in the desk an input from the keyboard. this method returns the number of drawers to the main method

a method to accept an input and return the type of wood 'm' for mahogany , 'o' for oak , or 'p' for pine

a method that accept the number of drawers and wood type, and calculate the cost of the desk based on the following:

pine 100$
oak 140$
all other woods 180$
a 30$ surcharge is added for each drawer
this method return the cost to main method

a method to display all the details and the final price


and i need to write it all in gui application

i started writing the code i am a beginner programmer
and i couldn't realize whet i am doing wrong

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace DesksGui
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {

            int drawers;
            int num;
            int desks;
            int type;


            desks = Convert.ToInt32(textBox1.Text);
            numberOfDrawers(num);
            woodType(string mahogany, string oak, string pine );



        }

        public static int numberOfDrawers(int number)
        {

             number = Convert.ToInt32(textBox2.Text);
            return number;

        }



         public int woodType(int m, int o, int p)
         {


             if (textBox3 = m)
             {

             }



            return m;

         }
    }






}

The first line is "Create a console-based application". Are you sure you need a GUI-based application?

Create a GUI app that accept desk order data from textBoxes and whose button's Click method calls all the methods described in exercise 9a. save the project as Desks.Gui

Create a GUI app that accept desk order data from textBoxes and whose button's Click method calls all the methods described in exercise 9a. save the project as Desks.Gui

I hate the word GUI! Even a ConsoleApp is in fact a GUI! Give me some time and I will draw an easter bunny in it! We don't use these so often any more.

a method to accept an input and return the type of wood 'm' for mahogany , 'o' for oak , or 'p' for pine

If you have a textbox, where you input a letter for the type of wood, what is the need for this method then? Just use textbox.Text.

commented: I agree, everything is graphical now, its really UX now :) +2

This is surely again one of the school projects.
You have to create a win form from console.

Ok, I did your homework, and here`s the code:

public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            int intDrawersPerDesk = 0;
            int intAllDesks = 0;
            //1. checking if textBox of wood type is empty:
            string strWoodType = textBoxWoodType.Text;                       
            if (strWoodType != String.Empty)
            {
                //2. checking if its a number for number of desks
                if (int.TryParse(textBoxDrawsPerDesk.Text.Trim(), out intDrawersPerDesk))
                {
                    //3. checking if its a number for number of drawers
                    if (int.TryParse(textBoxAllDesks.Text.Trim(), out intAllDesks))
                    {
                        //4. calculations, and checking of any of the numbers are zero
                        int intAllDrawers = NumberOfDrawers(intDrawersPerDesk, intAllDesks);                        
                        if (intAllDrawers > 0)
                        {
                            //5. checking exact wood type
                            string strShortWoodType = WoodType(strWoodType);
                            if (strShortWoodType != "error")
                            {
                                float fTotal = CalculateTotalCost(strWoodType, intAllDrawers);
                                MessageBox.Show("The total code is " + fTotal + ".");
                            }
                            else
                                MessageBox.Show("Please enter the correct wood type (mahogany, oak or pine).");
                        }
                        else
                            MessageBox.Show("Sum of all drawers is zero. Please higher the number of desk or drawers.");
                    }
                }
            }
            else
                MessageBox.Show("Please enter the correct wood type.");
        }

        private int NumberOfDrawers(int intDrawersPerDesk, int intAllDesks)
        {
            return intDrawersPerDesk * intAllDesks;
        }

        public string WoodType(string strTreeType)
        {          
            switch (strTreeType)
            {
                case "mahogany":
                    {
                        strTreeType = "m";
                        break;
                    }
                case "oak":
                    {
                        strTreeType = "o";
                        break;
                    }
                case "pine":
                    {
                        strTreeType = "p";
                        break;
                    }
                default:
                    {
                        strTreeType = "error";
                        break;
                    }
            }
            return strTreeType;
        }

        private float CalculateTotalCost(string type, int intAllDrawers)
        {
            float fCost = 0f;
            if (type == "p")
                fCost = 100 * intAllDrawers;
            else if (type == "o")
                fCost = 140 * intAllDrawers;
            else
                fCost = 180 * intAllDrawers;
            //adding a surcharge for each drawer:
            fCost = fCost + (intAllDrawers * 30);
            return fCost;
        }
    }

Thanks a million, Mitja
i learned a lot how get it all together from that code ,again thanks

No problem. I am glad I can help.
If the issue has been salved, simply mark the thread as answered or vote the post as helpful.

bye, bye
Mitja

hi mitja i need your help with C++ problem

the question is this

Write a program that asks the user for a string, then displays the length of the string, the string with the cases reversed, the string in all lowercase, and the string in all uppercase.

The main function should prompt the user, read in the string, and find and display the length. The main function should call three other functions (reverse, lower, and upper, in that order) and display the results.

The upper function should accept a pointer to a C-string as an argument. It should step through each character in the string, converting it to uppercase. The lower function should also accept a pointer to a C-string as an argument. It should step through each character in the string, converting it to lowercase. Like upper and lower, reverse should also accept a pointer to a string. As it steps through the string, it should test each character to determine whether it is upper- or lowercase. If a character is uppercase, it should be converted to lowercase. Likewise, if a character is lowercase, it should be converted to uppercase.


and my code is

#include <iostream>
#include <cstring>
#include <cctype>
using namespace std;

char* reverse (char*, int);
char* lower (char*, int);
char* upper (char*, int);

int main ()
{
const int SIZE = 80;
char myString [SIZE];
int strLength;

//Prompt user for string
cout << "Please enter a string.\n";

//read in string
cin.getline(myString, SIZE);

//find and display length
strLength = strlen(myString);
cout << "Your string is " << strLength << " characters long\n";

//call reverse function and output results in main to screen
//reverse(myString, strLength);
cout << "Your string reversed: ";
//for (int count = 0; count < strLength; count++)
cout << reverse(myString, strLength);
//cout << myString[count];
cout << endl;

//call lower function and output results in main to screen
lower(myString, strLength);
cout << "Your string in lowercase: ";
for (int count = 0; count < strLength; count++)
cout << myString[count];
cout << endl;

//call upper function and output results in main to screen
upper(myString, strLength);
cout << "Your string in uppercase: ";
for (int count = 0; count < strLength; count++)
cout << myString[count];
cout << endl;

return 0;
}

// function that reverses the case of string
char* reverse (char * string, int SIZE)
{
for(int count = 0; count < SIZE; count++)
{
if (isupper(string[count]))
tolower(string[count]);
else if (islower(string[count]))
toupper(string[count]);
}
return string;
}

// function that puts entire string in lower case
char* lower (char * string, int SIZE)
{
for(int count = 0; count < SIZE; count++)
tolower(string[count]);
return string;
}

// function that puts entire string in upper case
char* upper (char * string, int SIZE)
{
for(int count = 0; count < SIZE; count++)
toupper(string[count]);
return string;
}

thaks for the help

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.