Write a main program that performs the following steps: Prompt the user to enter a string, and let them type it in. This could be an entire sentence, with the newline indicating the end of the string. You may assume the string will be no more than 100 characters, so declare your array accordingly. Display the following menu: A) Count the number of vowels in the string B) Count the number of consonants in the string C) Convert the string to uppercase D) Convert the string to lowercase E) Display the current string F) Enter another string M) Display this menu X) Exit the program Enter a loop, allowing the user to type in a menu choice each time. Loop should continue until the user enters the command to exit. Upper and lowercase letters should be allowed for the menu choices. When the A or B commands are entered (counting vowels or consonants), call the corresponding function, then print the result When the C or D commands are chosen, just call the appropriate function to convert the string. Do not do any output from main on these commands. When E is chosen, print the contents of the stored string. When F is chosen, allow a new string to be typed -- this will replace the previous one. The menu should only be displayed once at the start, and then again whenever the M option is selected
tbshmkr
2009-01-14 21:38:53 UTC
Use any text editor. Pico, nano, beaver, vi,
Save your source code as [.cpp] dot cpp
How to compile the thing?
Assuming Linux and g++, (the C++ compiler flavor of gcc from gnu), at the command line you would just type:
g++ lesson1.cpp -o lesson1
StrifeDelivery
2009-01-14 21:06:31 UTC
you can write your .cpp file in any text editor. just use the linux notepad. depending on your distro and if you use gnome or kde it will always be diff. just change your save file to any type and add .cpp to your file name.you can do it from the command line, but i don't recommend that unless you have real experience. you can download compilers from any open source site, my versions of fedore and suse both came with one anyway. if you cant download one or are not sure how to install them once you do, just use the command line.
open the shell and type=> g++ -v
and press enter. if it returns something looking like a version # you can compile any saved text (.cpp) file
navigate using your shell to the directory your code is in and then just type=> gccp filename.cpp //filename being the name you saved it as
you make have to type sudo gccp filename.cpp if you are not the root user. if your system is set up correctly it will create a file called a.out in this directory and it will be your executable. type ./a.out to run your program
Lowell
2009-01-14 21:01:06 UTC
If you're already using Windows, stick with it for now. Learning a new environment while learning a new language is going to be overkill, **** what your teacher says. Besides, he won't be able to tell where the sources were written.
If Microsoft still has Visual C++ Express available use that or Netbeans 6. They're both all-in-one type environments.
A cpp file is just a text file that contains your sources.
shec0002
2009-01-14 21:00:40 UTC
I will assum that you have a terminal window, or you are sitting in front of a linux computer. After you have logged in you will either be facing a terminal window or a desktop. If you see a desktop find a way to start a terminal. In the terminal you need to use a text editor. For many years people have argued which is better vi or emacs, but now there are others. In the terminal on the command line type "vi helloworld.cpp" or "emacs helloworld.cpp" or "xemacs helloworld.cpp" or "vim helloworld.cpp" or "gedit hellowrold.cpp" or "nano helloworld.cpp". All of these are example of text editor in unix. Gedit is like windows notepad, and there are menus to save files. In vi and vim it isn't as obvious, it is the one that I use the most because you don't have to waste time touching your mouse. Whe vi starts you will see a blank screen press i to be in interactive mode. Type your code, and hist esc : w q this escapes you from interactive mode, and then writes and quite vi or vim. In xemacs and emacs you can use the mouse like notepad. In nano the commands are on the bottome of the screen. I hope this helps.
gnookergi
2009-01-14 20:57:48 UTC
You need to use a program like emacs. Go into the terminal and type in emacs then press enter. Or you can use Vi or nano. I don't know about your computer, but you also compile the .cpp file with the command "g++ -o programname filename.cpp" without the quotation marks. programfile is the name it will give the executable file it makes and filename.cpp is the file you programed.
Citrus
2009-01-14 21:04:49 UTC
I would use nano or pico which are installed by most linux distros by default and are easier for beginners than my preferred vim
so at the terminal type:
nano myprogram.cpp
that will create the file then you can type in your code press ctrl-x to close and save it.
then you should be back to your terminal so type:
g++ -o myprogram myprogram.cpp
then to run it type
./myprogram
ⓘ
This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.