Consider the following Java code for a method called "computeTotalSalary" and answer the following questions accordingly. public static double computeTotal5alary(double sales anount, double basic_salary) double commission; if (sales_amount >» 0.01 &a sales_amount < se00) commission - sales amount 0.06; else if (sales_amount >= 5000 &8 sales_amount < 18000 ) comnission- sales amount 0.08; else commission - sales amount 0.1; double total salary - basic_salary + connission; System.out.printf("Your total salary is $ x.2f \n", total_salary); return(total_salary); 1.2 Explain, in details, what is the functionality of this method.
Q: Write a Java Code for the below: A prime number is a number that is evenly divisible only by itself…
A: Here, Code instruction is given.
Q: (a) Write the static method numberOfLeapYears, which returns the number of leap years between year1…
A: ALGORITHM:- 1. Create object of the APCalendar class. 2. Call the numberOfLeapYears() function with…
Q: Suppose that a Scanner object contains a bunch of tokens all on a single line separated by spaces.…
A: import java.util.*;import java.lang.*;import java.io.*; class solution{ public static double…
Q: Write a method called min that takes three integers as parameters and returns the smallest of the…
A: Given: Write a method called min that takes three integers as parameters and returns the smallest of…
Q: LAB: Hailstone sequence (EO)
A: If num is even, divide it by 2 If num is odd, multiply it by 3 and add 1 (i.e. 3*num +1) Continue…
Q: Write a method named method1 that accepts two parameters: a maximum number and a number of stars.…
A: Program code: //import the required packages import java.util.Scanner; //define a class Main class…
Q: Write a java program that has the following methods: • A method called displaylncreasing that takes…
A: According to the Question below the Solution: Output:
Q: a) Write a method that calculates the result of the following formula: x² + (x + k}°+ (x + 2k) + (x…
A: The code in java has been given in step 2.
Q: 1 Theoretical Concepts Consider the following Java code for a method called "compute TotalSalary"…
A: Answer: the type of the computeTotalSalary is double. We can say that by seeing the method…
Q: For this exercise, you are given a Building class, a School class, and a House class. In the…
A: You can specify a method as overridden method by specifying @Override annotation or compiler will…
Q: Finish the method called waterTax() that will take a double units argument and returns a double bill…
A: Algorithm: 1. Take input unit from user 2. If unit entered is less than 50 then waterTax is unit x…
Q: in Java Language Write the method dateFashion(). * * You and your date are trying to get a table at…
A: A required program is as follows, public class DateFashion { /*The method, dateFahsion() takes…
Q: Theoretical Concepts Consider the following Java code for a method called "addTen" and answer the…
A: Given code: import java.util.*; import java.io.*; class Main { // Driver code public…
Q: For this problem you will write a method that computes the number of boxes in a pyramid of boxes…
A: Non Recursive Java Program Code Screenshot: Program Code to Copy class PyramidBoxCount { /**…
Q: If you don't decalre a method as public or private, would the method be defaulted to public, private…
A: When the user does not mention any access modifier like, “public” or “private” at the time of…
Q: Exercise 3: A. Write static methods: • public static double sphereVolume(double r) : r³ • public…
A: Here I have created a class named Geometry. In this class, I have created all 4 methods and then…
Q: A programmer notices that the following code snippet uses the same algorithm for computing cost…
A:
Q: 1 Theoretical Concepts Consider the following Java code for a method called "addTen" and answer the…
A: Given code:import java.util.*; import java.io.*; class Main { // Driver code public static…
Q: Write a method named raiseSalary that accepts two integers as an argument and returns its sum…
A: Hey! Thanks for the complete instructions. Here is the Source Code in Java: import…
Q: Create a program in Java called TicketPurchase. Create a method called receipt that will print each…
A: The program is written in java. Please check the source code and output in the following steps.
Q: How would you calculate the odds of customer winning a single purchased Lotto Game? Well, what are…
A:
Q: An integer number is said to be a perfect number if its factors, including 1 (but not the number…
A: PROGRAM CODE: import java.util.Scanner;public class Main { //creating scanner object to get…
Q: public void changeValues(int i, Card c) { i = 15; c.setSuit(“Clubs”); } Now consider the…
A: In method changeValues, the value of i is set to 15 but this change is bound to that particular…
Q: Question 2 Write a method int countMultiplesofFive (int x, int y) that returns the number of…
A: Given:
Q: Use the following to create a method java program. 2 pound or less as a starting point for shipping…
A: Introduction: Using the programme: Declare and set up variables shippingPrice and basePrice to hold…
Q: Using OOP language Java Given a currency with denominations of 100, 50, 20, 10, 5 and 1 write a…
A: Program DescriptionWe define a class called MakeChange which has a private static method called…
Q: Write a static method: public static double priceIsRight(Scanner s, double price) that takes a…
A: import java.util.Scanner;class Main{ static double priceIsRight(Scanner s, double price){…
Q: I NEED JAVASCIPT SOLUTION PLEASE Task An ATM only has 100, 50 and 20 dollar bills (USD)…
A: Step-1: StartStep-2: Declare a variable amount and take input from userStep-3: Call function…
Q: java programming Write a method that determines and returns the total number of all digits…
A: import java.util.Scanner;import java.util.*;import java.lang.*;public class MyClass { public…
Q: Write a static method avgNo Tens() that will receive two ints A and B and return the average of all…
A: The program for the above given question is given below:
Q: A Given the following code, what is the output? Assume a public number instance variable, and a…
A: Dear student, I'm providing the output as well as an explanation as per your requirement. I hope…
Q: in java 2.16 LAB: Driving cost - methods Write a method drivingCost() with input parameters…
A: logic:- calculate num_gallon=driven_miles/miles_per_gallon; calculate…
Q: Write a method named raiseSalary that accepts two integers as an argument and returns its sum…
A: Function:- public static double raiseSalary(int firstInt,int secondInt){ int…
Q: Write and test a method that can be used to determine the winner and increment either the user or…
A: import random user_score = int(0)pc_score = int(0)score_limit = 10 user_guess: str = input(str("pls…
Q: Computer Science Write a program for a toy-car manufacturing plant. Assuming that 10 toy-cars can…
A: According to the information given:- We have to follow the instruction to get bill for the customer…
Q: Write a program called AveMethod (main method) that contains a method called threeAve (method name)…
A: Write a program that follows the following conditions, a) The main method will do the following: •…
Q: You are asked to write a Java method that receives the Information Systems Department plan for first…
A: In questions with many questions, we must answer the first one.
Q: A. Write static methods: public static double sphereVolume(double r) : =tr³ public static double…
A: import java.util.Scanner; public class Lab7_yourID{ public static void main(String[] args) {…
Q: A method that asks for the username and password of the user. Note: Because we do not have any…
A: The code is below:
Q: Write the appropriate method headings using the provided method name for the following processes:…
A: The program is written in Java. Please find the source code and output in the following steps.
Q: 1 Theoretical Concepts Consider the following Java code for a method called "addTen" and answer the…
A: in main program number =15 when function addTen is called number becomes (number+=10 means…
Q: Create a java program that prompts the user for the number of pennies, nickels, dimes, quarters, and…
A: import java.util.Scanner;public class CoinsToDollarAmt { public static void main(String[]…
Q: Write a public static method name sumAll that takes in 2 arguments int a, int b, and returns the sum…
A: The function sumAll() contains following conditions: 1. If b is smaller than a, swap the values 2.…
Q: You are given a method with the signature: /** * Returns the minimum of the two numbers * *@param n1…
A: Please find the answer below
Q: Write a Java method that computes the future investment value at a given interest rate for a…
A: Method to calculate future investment value: public static double computeFutureInvestment(double…
Q: A pentagonal number is defined as n (3 n-1)/ 2 for n= 1, 2,.. so on. Therefore, the first few…
A: Note : As no language has been recommended here. So I am using the Java Programming language to…
Q: Write a method named checkScreenTime that accepts the age of a person. The method will display the…
A: Algorithm: Start Read age of a person Implement a method checkScreenTime which takes age as…
Q: od in Java named daysInMonth that accepts a month (an integer between 1 and 12) as a parameter and…
A: SUMMARYRoad to Java : Often, a method is a way of doing a particular job. Similarly, a path in Java…
Q: Exercise 2: A. Write static methods: public static double cubeVolume(double h) : h public static…
A: Below is the required Java program: - A. Program: - //Import the package import java.util.Scanner;…
Step by step
Solved in 2 steps
- Chapter 5. PC #13. isPrime Method A prime number is a number that is evenly divisible only by itself and 1. For example, the number 5 is prime because it can be evenly divided only by 1 and 5. The number 6, however, is not prime because it can be divided evenly by 1, 2, 3, and 6. Write a method named isPrime, which takes an integer as an argument and returns true if the argument is a prime number, or false otherwise. Demonstrate the method in a complete program. The program should ask the user to enter a number for primality test or a negative number to exit. Tip: Recall that the % operator divides one number by another, and returns the remainder of the division. In an expression such as num1 % num2, the % operator will return 0 if num1 is evenly divisible by num2. Test Case 1 Please enter a number to check for primality or -1 to exit:\n2ENTER2 is a prime number.\nPlease enter a number to check for primality or -1 to exit:\n3ENTER3 is a prime number.\nPlease enter a…In Java please 6.20 LAB: Hailstone sequence (EO) Given a positive integer num, the following rules will always create a sequence that ends with 1, called the hailstone sequence: If num is even, divide it by 2 If num is odd, multiply it by 3 and add 1 (i.e. 3*num +1) Continue until num is 1 Write a method, hailstone(), that takes in a positive integer as a parameter and prints the hailstone sequence starting with that integer. Format the output so that ten integers, each separated by a tab character (\t), are printed per line. Assume the input to the program is always positive. The output format can be achieved as follows:System.out.print(num + "\t"); Ex: If the program input is: 25 the output of method hailstone() is: 25 76 38 19 58 29 88 44 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 Note: Your program must define the method:public int hailstone(int num) import java.util.Scanner; public class Hailstone { public static void hailstone(int num){int i =…a.Write the method that finds the first 4 numbers out of 100 randomly generated numbers. After the numbers are generated in main, they should be sent to the method given as an example below and the smallest four numbers should be found. Write the numbers found on the console screen in the main method.(will be coded in java) Method name: public static int[] smallestFindFirstFourth(int[] array) Note: Sorting algorithms or ready-made functions will never be used. b.In the attached city list.txt file, the names of the provinces in Turkey are given in a single line according to the format given in Figure 1. In the application you will write, write the city names read from this file into the license plate list.txt file in the format shown in Figure 2. In more descriptive terms, citylist.txt is a file given to you. license plate list.txt is the file you will get with your code. city list: Adana, Adıyaman, Afyon, Ağrı, Amasya, Ankara, Antalya, Artvin, Aydın, Balıkesir, Bilecik, Bingöl, Bitlis,…
- 1) Through BlueJ, write if the current number of shoppers is greater than or equal to the number leaving then the number of shoppers is decreased by the number leaving. Otherwise, the following error message must be printed and the number of shoppers present must be set to 0. There is an error in the number of shoppers. Use System.out.println to print the message. 2) The class must define a method called leaving that takes a single integer parameter. This represents the number of shoppers leaving the club at a particular point. You may assume that the parameter's value will always be greater than zero and you do not have to check for that. If the current number of clubbers is greater than or equal to the number leaving then the number of clubbers is decreased by the number leaving. Otherwise, the following error message must be printed and the number of clubbers present must be set to 0. There is an error in the number of shoppers. Use System.out.println to print the error message. 3)…java programming: pleas see attachment as well***** In this task, you are asked to write a program called Swap.java, including at least 3 following methods: - Main() swapDigitPairs ( parameter) - swapLetterPairs (parameter) In the main method, - Use your Panther Number as the input argument, call swapDigitPairs ( parameter) - Ask user to input a number and call a method swapDigitPairs to swap the number as shown in the example of the following figure. - Ask the user to input a string of letters/numbers and call a method swapLetterPairs to swap the letters as shown in the following example. - swapDigitPairs ( parameter) - swapLetterPairs (parameter) In the main method, - Use your Panther Number as the input argument, call swapDigitPairs ( parameter) - Ask user to input a number and call a method swapDigitPairs to swap the number as shown in the example of the following figure. - Ask the user to input a string of letters/numbers and call a method swapLetterPairs to swap the letters…All coding is done in Java, using IntelliJ Idea. 3. Charge Account Validation Create a class with a method that accepts a charge account number as its argument. The method should determine whether the number is valid by comparing it to the following list of valid charge account numbers: 5658845 4520125 7895122 8777541 8451277 1302850 8080152 4562555 5552012 5050552 7825877 1250255 1005231 6545231 3852085 7576651 7881200 4581002 These numbers snould be stored in an array or an ArrayList Object. Prompt the user to choose search methodology between sequential/linear search, and binary search before the search is performed. Have the search locate the number passed as an argument. If the number is in the array, the method should return true, indicating the number is valid. If the number is not…
- Consider the following method. Java. public void changeValues(int i, Card c){ i = 15; c.setSuit(“Clubs”);} Now consider the following snippet of code that calls the method defined above. int num = 12;Card fiveOfSpades = new Card(5, “Spades”);System.out.println(“Before method call:”);System.out.println(num);System.out.println(fiveOfSpades.getSuit());changeValues(num, fiveOfSpades);System.out.println(“After method call:”);System.out.println(num);System.out.println(fiveOfSpades.getSuit()); What is the output of this code?Please help me with this , I am stuck ! PLEASE WRITE IT IN C++ Thanks 1) bagUnion: The union of two bags is a new bag containing the combined contents of the original two bags. Design and specify a method union for the ArrayBag that returns as a new bag the union of the bag receiving the call to the method and the bag that is the method's parameter. The method signature (which should appear in the .h file and be implemented in the .cpp file is: ArrayBag<T> bagUnion(const ArrayBag<T> &otherBag) const; This method would be called in main() with: ArrayBag<int> bag1u2 = bag1.bagUnion(bag2); Note that the union of two bags might contain duplicate items. For example, if object x occurs five times in one bag and twice in another, the union of these bags contains x seven times. The union does not affect the contents of the original bags. Here is the main file: #include <cstdlib>#include <iostream>#include "ArrayBag.h"using namespace std; template…Java programming. A method signature for a method consists of all elements of the method except the body. That is, a method signature consists of the privacy, (non-)static, return datatype, method name, and formal parameters. Consider the ceiling method as an example. public static int ceiling (double num) { return num <= 0 ? (int) num: (int) num + 1; } The method signature of the ceiling method is the first line of the method: public static int ceiling (double num). In this example, we note that ceiling is static because it is a standalone method and does not require an object to invoke (since we are not acting on an instance of a class). For parts a - d, give the method signature described by the scenario. a) A method in class String that returns the reversed version of the current String. b) A method that returns the maximum of two given integers. c) A method that returns true or false if the input integer is an even number. d) A default constructor for class Table.
- Write the method that finds the first 4 numbers out of 100 randomly generated numbers. After the numbers are generated in main, they should be sent to the method given as an example below and the smallest four numbers should be found. Write the numbers found on the console screen in the main method.(will be coded in java) Method name: public static int[] smallestFindFirstFourth(int[] array) Note: Sorting algorithms or ready-made functions will never be used.Chapter 5. PC #17. Rock, Paper, Scissors Game (page 317) Write a program that lets the user play the game of Rock, Paper, Scissors against the computer. The program should work as follows. 1. Add the following two lines to the beginning of your main method. This will allow your computer choices match with the test cases here in HyperGrade. long seed = Long.parseLong(args[0]); Random random = new Random(seed); 2. When the program begins, a random number in the range of 0 through 2 is generated. If the number is 0, then the computer has chosen rock. If the number is 1, then the computer has chosen paper. If the number is 2, then the computer has chosen scissors. (Do not display the computer choice yet.) 3. The user enters his or her choice of "rock", "paper", or "scissors" at the keyboard. You should use 1 for rock, 2 for paper, and 3 for scissors. Internally, you can store 0, 1, and 2 as the user choice, to match with the above schema. 4. Both user and computer choices…Chapter 5. PC #17. Rock, Paper, Scissors Game (page 317) Write a program that lets the user play the game of Rock, Paper, Scissors against the computer. The program should work as follows. 1. Add the following two lines to the beginning of your main method. This will allow your computer choices match with the test cases here in HyperGrade. long seed = Long.parseLong(args[0]); Random random = new Random(seed); 2. When the program begins, a random number in the range of 0 through 2 is generated. If the number is 0, then the computer has chosen rock. If the number is 1, then the computer has chosen paper. If the number is 2, then the computer has chosen scissors. (Do not display the computer choice yet.) 3. The user enters his or her choice of "rock", "paper", or "scissors" at the keyboard. You should use 1 for rock, 2 for paper, and 3 for scissors. Internally, you can store 0, 1, and 2 as the user choice, to match with the above schema. 4. Both user and computer choices…