Calculate the power of any number a raised to the exponent n

Assignment Help Programming Languages
Reference no: EM131270834

The Power function calculates the power of a base "a" raised to an exponent "n". Write a class which that you will call Power class with a method "power(a,n)" that prints the corresponding power value. Remember to use "float" for a and "long" for n and the returned value to be a "float" because the number is ***** real number.

Design and write a Dialog box for Input/Ouput that allows the users to input a base "a" and an exponent "n" and outputs the result of the power of a raised to the exponent of n.

Example:

Power(5.0,2)=(5.0)2= 25.0

Power(5.0,-2)=(5.0)-2 = (1/25)=0.04

Remember the values of n can be postive or negative. Your code should be able to deal with both cases. Remember to limit the value of n to the value 40 maximum.

The Assigment will require you to create 2 files:

1- Power.java which contain the details of creating the Power class and the method power which should calculate the power of any number a raised to the exponent n. (Use the Discussion 'Hints on Assign6" for help with writing the code for Power.java as an example). Remember that you are to create 2 loops in the "power(a,n)" method that you need to write: one loop for n>0 and one loop for n0. You need to cover both >0 and <0.

class Power{

float power (float x,long n){

float pow=1;

for(int i=0;i<n;++i)

pow=pow*x;

return pow;

}

}

Reference no: EM131270834

Questions Cloud

How is sales territory similar to entrepreneurial venture : How is a sales territory similar to an entrepreneurial venture? If a salesperson views his or her territory as an entrepreneurial venture, how might this change the way in which he or she approaches the management of the territory?
Compare manual operations : Describe the topic and specify what you learned from the video Explain the pros and cons of this approach Compare manual operations vs. the new computer-aided technology Find at least two additional references to support your paper
Evaluate the existing compensation plan : Evaluate the existing compensation plan to determine if it is the most appropriate for your company. Explain your rationale. Determine the most beneficial ratio of internally consistent and market consistent compensations systems for the company you..
About employee work-life balance : Do you think it's even important for a business to care about employee's work-life balance? How might this be evidenced in the “real world”? Can you provide some examples from your experiences?
Calculate the power of any number a raised to the exponent n : Power.java which contain the details of creating the Power class and the method power which should calculate the power of any number a raised to the exponent n.
Perform the pert-cpm calculations first : You will have to perform the PERT/CPM calculations first. Assume the total number of identical, full-time Type 1 resources available initially = 10, and Type 2 resources initially.
Human resources department of large company : If you were in the human resources department of a large company and needed to fill 10 entry-level positions working in a warehouse, and 2 management positions for the company, what selection tools would you choose for each and why? Choose at least t..
The program shall test to ensure that there is a punched in : The program shall test to ensure that there is a ‘Punched in' record for the corresponding day before a ‘punched out' record is saved. If none is found, prompt the user to enter a ‘punched in' time.
Benefits to family members of delivering hand massage : Benefits to Family Members of Delivering Hand Massage with Essential Oils to Critically Ill Patients Article. Which of these statements best describes this study’s research framework? This study has an implicit framework, which is not fully developed..

Reviews

Write a Review

Programming Languages Questions & Answers

  Write function which takes a string as the argument

Some examples are: "1234321", "C", "ABCBA". Write down a function which takes a string as the argument and returns 1 if string is palindrome and 0 otherwise.

  Program to evaluate postfix expressions using a stack

Program to evaluate postfix expressions containing complex numbers using a stack. This program should contain two classes. T

  Write a procedure make-accumulator

Write a procedure (make-queue) that produces independent first-in-first-out queue objects, using a message-passing style.

  Find the output displayed when the button is clicked

Determine the output displayed when the button is clicked

  Determining whether it is possible to reuse code

You are a project manager and have been told that you need to reuse some given code in your new development effort. How would you go about determining whether it is possible to reuse code for this effort?

  Compute and display number of miles per hour

Once correct data has been entered, the program muts compute and display number of miles per hour over the speed limit that the driver was doing.

  Explain usability and accessibility in site design

A description of content to be included in site and how this content will be acquired. Attention should be given to copyright restrictions.

  Program to execute on cse unix environment

Your program should be written in C++, execute correctly on CSE unix environment, and compile using g++ compiler using makefile.

  Design a program allow the user to select air

Design a program that displays a menu allowing the user to select air, water, or steel. After the user has made a selection, he or she should be asked to enter the number of seconds the sound will travel in the selected medium

  Pseudocode to create thread-safe countdownevent by locks

Write pseudocode to implement a thread-safe CountdownEvent using locks and condition variables by implementing the following methods (lists 4 methods) and then "implement a Barrier using a CountdownEvent.

  Write program which reads data into type integer

Write down the program which reads data into type int. Valid values are from 0 to 10. The program must find out how many values were inputted.

  Create a user form that contains the usual ok and cancel

Create a user form that contains the usual OK and Cancel buttons

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd