Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please solve it solve all questions in java please all questions don't used Arrays please Lab 3: Methods Objectives To practice more about methods (create,

please solve it

solve all questions in java please all questions don't used Arrays please

image text in transcribed

Lab 3: Methods Objectives To practice more about methods (create, invoke and pass arguments). To determine the scope of variables. Exercises can X + + 1. The exponential et be calculated using the following formula: x2 x3 x4 x5 ex = 1 + + + 1! 2! 3! 4! 15! The factorial of non-negative integer n is written n! And is defined as follows: n! = n(n-1).(n-2).....1 n! = 1 (if n = 0) Write a java program that contains two methods factorial and exp according to the formulas that we mentioned above. The main task for this program is to ask the user to enter a number and calculate its exponential then display the result. Note that exp method will call factorial method. 2. An integer number is said to be perfect number if the sum of its factors including 1 (but not the number itself) is equal to the number itself. For example 6 is perfect because 6 = 1 + 2 + 3. Write a method is PerfectNumber using the following signature that determines if parameter number is perfect number. Use this method in a main method that determine and prints all the perfect numbers between 1 and 1000. public boolean is perfectNumber( int number) 3. Write a java method that accepts a binary number and converts it to decimal then display the result. For Example: (110)2 = (610 (22*1)+ (21 +1) + (200) = 6 Additional task: write a method that accepts a decimal and converts it to binary

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Database Programming

Authors: Chris Fehily

1st Edition

1937842312, 978-1937842314

More Books

Students also viewed these Databases questions