Write a program to convert decimal to octal or decimal to hexadecimal or decimal to binary digits and then display the decimal number along with its changed form. Use only for loop or while loop and java.util.* package
(E.g.)The output must be like below-
Press A to convert the decimal into octal:
Press B to convert the decimal into hexadecimal:
Press C to convert the decimal into binary:
Enter a decimal number: 4.8
Its binary form: 100.11001100110
_______________________________________________________________________
**I pressed C so I got its binary form, If I have pressed B then it would have been like this-
Its hexadecimal form: 4.CCCCCCCCCCC
BTW above is for 4.8e10
Write a program to check and display whether the number is Goldbach number or not using only for loop or while loop & java.util.* package
The output must be like below-
Enter a number:
6
Goldbach number
Your task is to find the sum of the length of all lines (in kms) that can be drawn between co-ordinates of these countries.
Population limit: 65847
Your task is to find the sum of the length of all lines (in kms) that can be drawn between co-ordinates of these countries.
Create a program using recursion with data structure show the code and the output.
class QuizBrain:
def __init__(self, q_list):
self.question_number = 0
self.question_list = q_list
def still_has_question(self):
if self.question_number < len(self.question_list):
return True
else:
False
def next_question(self):
current_question = self.question_list[self.question_number]
self.question_number += 1
user_answer = input(f"Q.{self.question_number}: {current_question.text} (True/False):")
self.check_answer(user_answer, current_question.answer)
def check_answer(self, user_answer, correct_answer):
if user_answer.lower() == correct_answer.lower():
print("You got this right!")
else:
print("That's wrong")
print(f"The correct answer was: {correct_answer}")
add a score:
sample output:
Your Score is 1/1
Write a do-while loop that continues to prompt a user to enter a number less than 100, until the entered number is actually less than 100
Type a statement using srand() to seed random number generation using variable seedVal. Then type two statements using rand() to print two random integers between (and including) 0 and 9
by CodeChum Admin
We've already made listing an array the easy way, but how about listing and printing the array in reverse order?
Make a program that will input an integer and then using loops, add items on an array/list one by one for the same number of times as that of the first inputted integer. Then, print out the array/list in ascending order. After doing that, print the array again on the next line in reverse order, that is, starting from the last item on the array/list down to the first one, each in separated lines.
Input
The first line contains the size of the array.
The next lines contains the items of the array (integers).
5
1
64
32
2
11Output
The first line contains the elements of the array printed in ascending order.
The second line contains the elements of the array printed in reversed order.
1·64·32·2·11
11·2·32·64·1by CodeChum Admin
I have an array of 3 numbers here with me that's already in the code editor, but I want you to add some more to this list by inputting some more numbers yourself in one line and then, print out only the even numbers from the array.
Can you do that for me?
Input
The first line contains the number of elements, n, to be added.
The next line contains the n integers separated by a space.
5
33·54·32·11·8Output
Multiple lines containing an integer.
2
54
32
8