Request this to be done in JGrasp
1.Add a method to the program that calculates the cube of every number between a lower bound and an upper bound that a user inputs (for instance, lower bound 1 and upper bound 9, for between 1 and 9).
2. Write an additional method that return the cubed value of an integer
3.Write an additional method to accomplish the same thing in #1, but this time calls the method you wrote in #2
1 ans
methodd to the program that calculates the cube of a number is to be
Math.pow(m,n)
it is used to get the power of any base ,it will return m to the power of n (m^n).
program:
import java.util.*;
public class code
{
public static void main(String args[])
{
int lb,ub;/*lb=lower bound; ub=upper bound*/
System.out.println("enter lower bound");
Scanner in=new Scanner(System.in);
lb=in.nextInt();
System.out.println("enter upper bound");
ub=in.nextInt();
while(lb<ub)
{
lb=++lb;
System.out.println("cube of/n"+lb+"is:"+ Math.pow(lb, 3));
}
}
}
2 ans and 3 ans
additional method to return value of the integer
import java.util.*;
public class main
{
public static void main(String args[])
{
int lb,ub;
System.out.println("enter lower bound");
Scanner in=new Scanner(System.in);
lb=in.nextInt();
System.out.println("enter upper bound");
ub=in.nextInt();
cubedNumber(lb,ub);
}
public static int cubedNumber(int lb,int ub)
{
while(lb<ub)
{
lb=++lb;
System.out.println("cube of/n"+lb+"is:"+ Math.pow(lb, 3));
}
return lb;
}
}
Request this to be done in JGrasp 1.Add a method to the program that calculates the...
Program#3(17 points): write a java program (SunDigits) as follows The main method prompts the user to enter an integer number. The method then calls Method Sum (defined blew) to add the digits and return their total. The main method then prints the digits total with proper label as shown below Method Sum )is of type integer and takes an integer value. The method recursively adds up the digits and returns their total. Document your code and use proper prompts for...
Need to be solved in c# Write the program using the method that calculates the cube of numbers from 1 to 9 that comes as a parameter to it as a series.
QUESTION 12 Write a program that would prompt the user to enter an integer. The program then would displays a table of squares and cubes from 1 to the value entered by the user. The program should prompt the user to continue if they wish. Name your class NumberPowers.java, add header and sample output as block comments and uploaded it to this link. Use these formulas for calculating squares and cubes are: square = x * x cube = x...
Write a class that analyzes data you have stored in a text file. Your data represents the ages of the individuals in your fictitious community. The data is stored, one per line, in a text file. For example, File name: myData.txt Contents: 45 18 6.5 3 5 sdtypo# 18 10 The number of lines in your text file must fall somewhere between 20 and 100 lines. Some of the lines must hold character strings that are not convertible to integers,...
PLEASE INCLUDE COMMENTS In java Create a Java Program Add the following comments at the beginning of the file: Your name. The name of the class(es) used in the program. The core concept (found below) for this lesson. The date the program was written. Include a recursive method separate from the main method that will add together all of the even numbers between and including 1 and the value the user supplies. For instance, if the user enters 10 then...
Write a C program to do the following 1) request user to enter 10 integer into an array 2) sort the array in ascending order 3) display the sorted array 4) count the number of odd and even number in the array and print out the result 5) add the value of the odd number and even number and calculate the average of the odd and even number. display the result 6) write function addNumber() to add all the number...
Create a class fully-qualified as edu.udc.cs 1. ArrayWork. This class should have a static method that takes an integer array with at least 1 element. All elements will be more than 0. The method must return a double array of the same size filled with normalized values at the same positions. Normalized values will be a value between 0 (exclusive) and 1 inclusive. Simply, it will be every input value divided by the maximum value in the input. For instance...
Exercise 4-4 Create an object and use it with the Number Guessing Game In this exercise, you’ll convert a number guessing game so it uses some object-oriented features. The class we create will have 3 private instancevariables, 2 constructors, 3 getmethodswhich return a value, and 1 methodthat acts as a sub procedure. The logic for creating a random number and tracking the # of guesses is moved to this new class. Review the project Start NetBeans and open the project...
Task 1: 1. Write a generic class named MyList, with a type parameter T. The type parameter T should be constrained to an upper bound: the Number class. The class should have as a field an ArrayList of type T. Write the class constructor to create the ArrayList. 2. Write a public method named add, which accepts a parameter of type T. When an argument is passed to the method, add it to the ArrayList. 3. Write a public method...
(COs 1 and 8) Create a Python program that calculates the tip and total for a meal at a restaurant. Paste Python code here; output not required. Sample output: Tip Calculator Enter cost of meal: 52.31 Enter tip percent: 20 Tip amount: 10.46 Total amount: 62.77 Specifications: •Input: costOfMeal, tipPercent The formula for calculating the tip amount is: tip = costOfMeal * (tipPercent / 100) • The program should accept decimal entries like 52.31 and 15.5. • Assume the user...