Question

In: Computer Science

Create a calculator in java without using the math library which converts an integer into a...

Create a calculator in java without using the math library which converts an integer into a hexadecimal number.

Solutions

Expert Solution

// Java Code

import java.util.Scanner;
public class Main
{
public static void main(String args[])
{
Scanner input = new Scanner( System.in );
System.out.print("Enter an integer : ");
int num =input.nextInt();
// For storing remainder
int rem; // Variable Declaration
// For storing result
String str2="";
   // Digits in hexadecimal number system
char hex[]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
   while(num>0)
{
rem=num%16;
str2=hex[rem]+str2;
num=num/16;
}
System.out.println("Decimal to hexadecimal: "+str2);
}
}

Editor Snapshot:

Output Sapshot:


Related Solutions

How do I solve this system of equations without using a calculator or fancy matrix math?...
How do I solve this system of equations without using a calculator or fancy matrix math? v1 = 1.8 v2 = ? v3 = ? (1) v1 = 1.8 (2) 7150v2+1350v3  = 12780 (3) 7150v22 + 1350v32 = 23166
create scientific calculator using java language with OOP rule and interfaces.
create scientific calculator using java language with OOP rule and interfaces.
create calculator standard using java language with OOP rule and interfaces.
create calculator standard using java language with OOP rule and interfaces.
Using Java: Create a class called MyNumber with an integer private attribute. Create a constructor that...
Using Java: Create a class called MyNumber with an integer private attribute. Create a constructor that defines an integer parameter to set the private integer attribute. Create a setter that validates the attribute does not accept a value lower than 2 or the method will throw a IllegalArgumetException. Create a getter to return the private integer attribute value. Define a public method that is called isPrime() that returns a boolean and implements the Sieve of Eratosthenes method. Define a public...
Plot the function without using a calculator, as you will not have a calculator on the...
Plot the function without using a calculator, as you will not have a calculator on the exams. a. ? = 34 sin ?, from t = 0 to the end of the first cycle only. b. ? = 2sin3?, from t = 0 to the end of the second cycle only. c. ? = 2cos3?, from t = 0 to the end of the second cycle only. d. ? = 2sin??, from t = 0 to the end of the...
I am doing a 4 function calculator app in java on android studio which calculates math...
I am doing a 4 function calculator app in java on android studio which calculates math expressions (add, subtract, multiply, and divide). I ONLY NEED THE CODE THE EQUAL BUTTON. When the user clicks the equal button, it should take the entire sequence of numbers and operators on the screen, such as 1+2*5 , and save them into a String [I am pretty sure this can be done using the toString() call]. Then, the String should be split using StringTokenizer,...
Introduction to Java Programing Using Loop Create a simple calculator program using loop Ask user to...
Introduction to Java Programing Using Loop Create a simple calculator program using loop Ask user to input two numbers using scanner class Print the instruction of the menu for the calculator program Ask user to press 0 to Quit Ask user to press 1 to Add Ask user to press 2 to Substract Ask user to press 3 to Multiply Ask user to press 4 to Divide Perform correct calcuation based on user inputs and print the result Print error...
Using Linked List, create a Java program that does the following without using LinkedList from the...
Using Linked List, create a Java program that does the following without using LinkedList from the Java Library. and please include methods for each function. Create a menu that contains the following options : 1. Add new node at the end of LL. ( as a METHOD ) 2. Add new node at the beginning of LL. ( as a METHOD ) 3. Delete a node from the end of LL. ( as a METHOD ) 4. Delete a node...
Create a Java program with a method that searches an integer array for a specified integer...
Create a Java program with a method that searches an integer array for a specified integer value **(see help with starting the method header below). If the array contains the specified integer, the method should return its index in the array. If not, the method should throw an Exception stating "Element not found in array" and end gracefully. Test the method in main with an array that you make and with user input for the "needle". starting header ** public...
Integer value calculator: Write a program using C++ that acts as a calculator. The program should...
Integer value calculator: Write a program using C++ that acts as a calculator. The program should ask the user for two numbers and an operator. Then the program must print the result using the two input values and the operator. Prompts and input requirements. Ask the user for two integer values and a value that indicates the operation. Likely you will want to choose the normal operators: + - * / %. Output Requirements: Make your output easy to understand,...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT