Hey all
names william
I am in my first year uni - doin bachelor of computin and hence dont no much bout programming
I have to submit this assingment tomorow and am confused as to what I am supposed to be doin
I would appriciate any elp from any1
I will put the question up first and then what I have written pls point me in the right direction
Question
Write a C++ program with a case structure. The program reads in a character from the user, then display its translation according to the following rules:
i. characters A, E, I, O, U will be translated to characters a, e, i, o, u respectively;
ii. the space character ' ' will be translated to underscore '_'
iii. digits 0, 1, 2, .., 9 will all be translated to '#'
iv. all other characters remain unchanged
The program then displays the translated character.
NOTE: You can make use of cin.get() to get the next character even if that character is a white space, see for example,
MY ANSER:
( Note - I am using Dev c++ as the compiler - uni standards)
#include<iostream>
using namespace std;
int main()
{
char ch;
cout << "Enter a char:";
ch=cin.get();
cout << "1st char has code " << unsigned(ch)
<< " and is \"" << ch << "\"\n";
system("pause");
return 0;
}
QUESTON:
Write a C++ program that reads from keyboard 3 words, with proper input prompt. Then for these 3 words that were read, the program displays first the word of the longest length, then the word of the shortest length, and finally the remaining last word. You may assume that these 3 words are all different in lengths, or consider a word to be of the longest length if no other words exceed it in length.
MY ANSWER:
# include <iostream>
using namespace std;
int main()
{
char word1, char word2, char word3;
cout << "Enter word1: " <<endl;
cin >>word1;
cout <<"Enter word2: " <<endl;
cin >>word2;
cout << "Enter word3: " <<endl;
cin >>word3;
system ("pause");
return 0;
}
I Know this is a lot to be asking but please help