Help with Homework... Time is almost up.

I am currently working on my homework and I am having a little trouble with the assignment. This is the assignment:

Design, write and test a program to meet the following specifications.

1. Print a title for the program and then display a clear prompt for the user to enter a character in the range of ‘a’..’f’.

2. Validate the user input: print an error message if the input is out of range (not in the range ‘a’..’f’)

3. Process the valid input as follows

a. First, prompt for and read three integers

b. Print the following results based on the input from the user

Option Output

a The 3 integers in order from smallest to largest

b The absolute values of the integers

c The floating point average of the integers

d The number of integers that are the same

e The number of even and the number of odd values input

f The floating point average of the positive integers

Restrictions:

Only use the language constructs covered in class.

The options must be handled using a switch statement.

I know its a lot to ask, but could anyone please give me examples of how to code options a-f within the restrictions given? This is due to tommorow and I really want to be able to turn in my assignment so I don't get dropped (my teacher is very strict and also moving so fast that I am having trouble keeping up with this course). Thanks for any assistance!

Sincerely,

KT

Just an another common way to do (a)

Code:

`(a) `

#include<iostream>

using namespace std;

void Assend();

int input[2];

int i1,i2,i3;

void Assend(){

input[0]=i1;

input[1]=i2;

input[2]=i3;

int size = 3, temp;

// Bubble sort

for(int x=0; x<(size-1); x++)

for(int y=1; y<(size-x); y++){

if ( input[y-1] > input[y] ){

temp = input[y-1];

input[y-1]=input[y];

input[y] = temp;

}

}

cout<<input[0]<< ", " << input[1] << ", " << input[2] << ", " << endl;

}

void main()

{

char c;

cout<< "Enter a character a-f: " ;

cin>> c;

bool valied = (int)c>102;

if(valied)

cout<<"Charactor out of range"<<endl;

cout<< "Enter an integer: "<<endl;

cin>>i1;

cout<< "Enter a 2nd integer: "<<endl;

cin>>i2;

cout<< "Enter a 3rd integer: "<<endl;

cin>>i3;

switch(c)

{

case 'a':

Assend();

}

}

Re: Just an another common way to do (a)

Quote:

*Originally posted by kasun * Code:

`(a) `

void Assend();

int input[2];

int i1,i2,i3;

void Assend(){

input[0]=i1;

input[1]=i2;

input[2]=i3;

int size = 3, temp;

...........................

..........

sorry Kasun but i think you should make the following

because input[2] means only two elements not three in the array but u needed here three elements of the array input