2 Replies - 1797 Views - Last Post: 09 February 2008 - 01:28 PM Rate Topic: -----

#1 dwd3773  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 103
  • Joined: 09-February 08

functional decomposition

Post icon  Posted 09 February 2008 - 08:59 AM

I am trying to do a problem and I cant seem to figure out how to get started. The problem wants me to allow the user to input a letter (A-Z) and the program to output a corresponding phonetic alphabet word ie. Alpha, Bravo and so on. But I cant seem to figure out how to link the user input to the corresponding phonetic alphabet word. Im not asking for anyone to do the whole problem just give a hint or two or maybe even guide me toward a tutorial that might help.

Is This A Good Question/Topic? 0
  • +

Replies To: functional decomposition

#2 no2pencil  Icon User is online

  • Admiral Fancy Pants
  • member icon

Reputation: 5411
  • View blog
  • Posts: 27,425
  • Joined: 10-May 07

Re: functional decomposition

Posted 09 February 2008 - 09:06 AM

View Postdwd3773, on 9 Feb, 2008 - 08:59 AM, said:

I am trying to do a problem and I cant seem to figure out how to get started. The problem wants me to allow the user to input a letter (A-Z) and the program to output a corresponding phonetic alphabet word ie. Alpha, Bravo and so on. But I cant seem to figure out how to link the user input to the corresponding phonetic alphabet word. Im not asking for anyone to do the whole problem just give a hint or two or maybe even guide me toward a tutorial that might help.

Have them input a letter, upper case it, & use a select case to output what word associates with that letter.
Was This Post Helpful? 1

#3 dwd3773  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 103
  • Joined: 09-February 08

Re: functional decomposition

Posted 09 February 2008 - 01:28 PM

Thanks for the help, but I have to use an if statement since that is what the chapter's over so I can get full credit for the problem. I think I figured out how to do but please review the code below and see if you now how I can streamline the code or any comments or tips.
#include <iostream>									 // Access cout
#include <cmath>										// Access power function
#include <iomanip>										// Access manipulators

using namespace std;

int main()
{
	// Local variables
	char LETTER;											  // Input from user

	cout << "Please enter a capital letter (A-Z). " << endl;  // Prompt
	cin >> LETTER;											  // Letter input

	cin.get();

	// Nested if statement that output results depending on input letter.
	if (LETTER == 'A')
		cout << "Alpha" << endl;
	else if (LETTER == 'B')
		cout << "Bravo" << endl;
	else if (LETTER == 'C')
		cout << "Charlie";
	else if (LETTER == 'D')
		cout << "Delta";
	else if (LETTER == 'E')
		cout << "Echo";
	else if (LETTER == 'F')
		cout << "Foxtrot";
	else if (LETTER == 'G')
		cout << "Golf";
	else if (LETTER == 'H')
		cout << "Hotel";
	else if (LETTER == 'I')
		cout << "India";
	else if (LETTER == 'J')
		cout << "Juliet";
	else if (LETTER == 'K')
		cout << "Kilo";
	else if (LETTER == 'L')
		cout << "Lima";
	else if (LETTER == 'M')
		cout << "Mike";
	else if (LETTER == 'N')
		cout << "November";
	else if (LETTER == 'O')
		cout << "Oscar";
	else if (LETTER == 'P')
		cout << "Papa";
	else if (LETTER == 'Q')
		cout << "Quebec";
	else if (LETTER == 'R')
		cout << "Romeo";
	else if (LETTER == 'S')
		cout << "Sierra";
	else if (LETTER == 'T')
		cout << "Tango";
	else if (LETTER == 'U')
		cout << "Uniform";
	else if (LETTER == 'V')
		cout << "Victor";
	else if (LETTER == 'W')
		cout << "Whiskey";
	else if (LETTER == 'X')
		cout << "X-ray";
	else if (LETTER == 'Y')
		cout << "Yankee";
	else if (LETTER == 'Z')
		cout << "Zulu";

	cin.get();
}


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1