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 a haskell program to calculates a balanced partition

Write a program in Haskell which calculates a balanced partition of N items where each item has a value between 0 and K such that the difference b/w the sum of the values of first partition,

  Create an application to run in the amazon ec2 service

In this project you will create an application to run in the Amazon EC2 service and you will also create a client that can run on local machine and access your application.

  Explain the process to develop a web page locally

Explain the process to develop a Web page locally

  Write functions

These 14 questions covers java class, Array, link list , generic class.

  Programming assignment

If the user wants to read the input from a file, then the output will also go into a different file . If the user wants to read the input interactively, then the output will go to the screen .

  Write a prolog program using swi proglog

Write a Prolog program using swi proglog

  Create a custom application using eclipse

Create a custom Application Using Eclipse Android Development

  Create a application using the mvc architecture

create a application using the MVC architecture. No scripting elements are allowed in JSP pages.

  Develops bespoke solutions for the rubber industry

Develops bespoke solutions for the rubber industry

  Design a program that models the worms behavior

Design a program that models the worm's behavior.

  Writing a class

Build a class for a type called Fraction

  Design a program that assigns seats on an airplane

Write a program that allows an instructor to keep a grade book and also design and implement a program that assigns seats on an airplane.

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