Programming
Java question

Question Description

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


Final Answer

#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));
}
}

prince9599 (43)
New York University

Anonymous
Top quality work from this tutor! I’ll be back!

Anonymous
It’s my second time using SP and the work has been great back to back :) The one and only resource on the Interwebs for the work that needs to be done!

Anonymous
Thanks, good work

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4

Brown University





1271 Tutors

California Institute of Technology




2131 Tutors

Carnegie Mellon University




982 Tutors

Columbia University





1256 Tutors

Dartmouth University





2113 Tutors

Emory University





2279 Tutors

Harvard University





599 Tutors

Massachusetts Institute of Technology



2319 Tutors

New York University





1645 Tutors

Notre Dam University





1911 Tutors

Oklahoma University





2122 Tutors

Pennsylvania State University





932 Tutors

Princeton University





1211 Tutors

Stanford University





983 Tutors

University of California





1282 Tutors

Oxford University





123 Tutors

Yale University





2325 Tutors