Java question

label Programming
account_circle Unassigned
schedule 3 Days
account_balance_wallet $5

ecimal to hex) Write a program  that prompts the user to enter an integer  between  0 and 15 and displays its corresponding hex number.

INPUT and PROMPTS. The program  prompts for a integer  with: "Enter a decimal value  (0 to 15): ".

OUTPUT . If the integer  read in is equal  to the value  of a single hexadecimal  digit (i.e. in the range specified by the prompt), the program  prints out "The hex value  is x", where x is the hexadecimal  digit corresponding to the input; otherwise it prints the message  "Invalid input".

CLASS  NAMES. Your program  class  should be called  Hex


Sep 27th, 2013
#include<iostream>
using namespacestd;

int absolute(int v); //OR use abs() predefined function from cstdlib
void printAscendingTriangle(int input);
void printPattern(int input);
void printDescendingTriangle(int input);

void main(void)
{
int input;

cout << "Input an integer: ";
cin >> input;

if(input > -3 && input < 3)
{
cout << "Invalid range." << endl;
}
else if(input % 2 == 0)
{
cout << "Odd integers only." << endl;
}
else
{
printAscendingTriangle(absolute(input));
printPattern(input);
printDescendingTriangle(absolute(input));
}
}
Sep 27th, 2013

Did you know? You can earn $20 for every friend you invite to Studypool!
Click here to
Refer a Friend
...
Sep 27th, 2013
...
Sep 27th, 2013
Jun 26th, 2017
check_circle
Mark as Final Answer
check_circle
Unmark as Final Answer
check_circle
Final Answer

Secure Information

Content will be erased after question is completed.

check_circle
Final Answer