TASK 5. Methods Overloading. Review Methods, Implement the following code, test it with different input, make sure it runs without errors.
Q: Write the studentRecord method finalAverage (), You MUST call the methods average () and…
A: public class StudentRecord{ private int[] scores; private String make_up; public…
Q: create java method to count the number of employees and their salary ranges according to your…
A: ALGORITHM:- 1. Declare and initialise 2 arrays , one of name and other of salaries. 2. Pass both the…
Q: Create a class to print the area of a square and a rectangle. The class has two methods with the…
A: Required: Required code with comments for explanation and screenshot of both code and output has…
Q: Task -6 Given the following classes, write the code for the Triangle and the Trapezoid class so that…
A: Solution :
Q: You can see that students have a name, a number, some marks for subjects they are studying and the…
A: The given UML diagram is:
Q: These two pictures are my resource and driver classes. Please, help me with the error in my resource…
A: Formula to calculate the new salary using the percentage raise on salary: salary…
Q: # Add your other test methods here
A: import unittest fromo fluffy_functions import all_fluffy class TestAllFluffy(unittest.TestCase):…
Q: What methods are created automatically when a new test class is created?
A: In C++ ,if we write а сlаss thаt hаs nо methоds in it, аnd the сlаss dоes nоt…
Q: 1 1 2 1 1 2 1 2 3 4 5 3. 4- 2.
A: rows = 6for row in range(1, rows): num = 1 for j in range(rows, 0, -1): if j > row:…
Q: What do you called adding the final keyword in the method declaration? Answer:
A: The above question that is when we add final keyword in. Method declaration is answered in next…
Q: Write VM instructions that translate the assignment (let) statement that is in the body of the…
A: let x be al+a2 in local 1let z be x*x in local 2let y be x-z in local 3do return y endend…
Q: Write the Director class with the required methods to give the following outputs as shown.
A: Here I have done the code in Python(since no programming language is mentioned). Algorithm : class…
Q: 1. What is the correction for the error (where llerror is marked) (5 Points) Enter your answer 2.…
A: The answer is given below.
Q: Give an example where the read one, write all that you can method leads to a bad situation.
A: Approach: Read one, write whatever that comes to mind: This strategy may be used to handle…
Q: Fill in the missing parts of the below method. The method is named calcMPG. It takes in two…
A: Given:- Fill in the missing parts of the below method. The method is named calcMPG. It takes in…
Q: First, in a few phrases, explain what a method is, and then proceed to go over its three basic…
A: MethodOnce you have built things, you want those objects to be able to do some action once you have…
Q: Which of the following best explains why the getAge method will NOT work as intended?
A: In function you can see the getter (accessor) is getAge and it is returning the weight. but for…
Q: Examine the following method header; then write an example call to the method. private void…
A: Example call to the given method: Method header consists of an access modifier, method name,…
Q: 1. Create two (2) overloaded methods that display a greeting message and use first name and last…
A: “Since you have asked multiple questions, we will solve the first question for you. If you want any…
Q: Write the heading (not the method body) for a public method called writeDate that takes three int…
A: Different ways of declaring given parameters month ,day and year in classDate public method. //1)…
Q: I keep getting the error TypeError:int object is not subscriptable. I've tried removing the text and…
A: Hi, For the given code, there is an error. I have fixed it below. The list where numbers are getting…
Q: Get to know about the proof-carrying code, a method in which the provider of mobile code provides an…
A: Introduction: A method is known as Proof-Carrying Code (PCC) allows untrusted code to be executed…
Q: What is the list of all the methods of the Card class, and for each one write what type( if any) the…
A: Dear Student, The method used in class card are - __str__() and __lt__()
Q: Duplicate method actionPerformed(ActionEvent) in type Calc i am having this error in my JAVA…
A: public class Calc extends JFrame implements ActionListener { private Button button1;…
Q: Building a program that contains a class with a set of methods inside it, and it is called by the…
A: A class is a collection of items with similar characteristics. It is a blueprint or template from…
Q: How we can execute any code even before main method?
A: let us see the answer:- Yes, We can run code before calling the main method. And to accomplish…
Q: Compare the method headers of GetPrice and printTicket in Code 2.1. Apart from their names, what is…
A: To compare the method headers of GetPrice and printTicket.
Q: Write a BankAccountTester class whose main method constructs a bank account, deposits $1,000,…
A: So we just have to use the concept of OOP's and access the data members from class BankAccount : I…
Q: In this challenge activity, you will analyze the numbered steps to make vanilla ice cream and…
A: Inputs are the objects that were given by user to machine or the basic components to begin the…
Q: Please help with this, I am kinda lost. bagDifference: The difference of two bags is a new bag…
A: Python 2.7 code : #function to find difference between two bags i.e (bag1 - bag2)def…
Q: What kind of methods are two or more methods with the same name but different parameterLists?
A: Answer: Method overloaded
Q: Examine the method header below, then write a call to the method as an example. a personal void…
A: Example call to the given method: Each method header contains a collection of statements that must…
Q: True or False? Interface can be used to store a common method implementation.
A: The question is about whether an interface can have a common method implementation in it or not. Can…
Q: Can someone answer the task below?
A: #include <iostream> using namespace std; int main(){ string Name; double FNPF, AI,…
Q: If a class extends Applet and also implements MouseListener and MouseMotionListener, what methods…
A: Java is a programming language. It contains extensive libraries (package). It can be used to create…
Q: If two methods have same name but different parameter list then it is called
A: Operator overloading - It is a compile-time polymorphism in which the operator is overloaded to…
Q: Create a method where a goblin will attack a zombie as long as the zombie has no health,…
A: Below is the method written in C++ as language not specified and sample output:
Q: Examine the method header below, and then write a call to it as an example. void private ShowValue()
A: An example of a call to the specified method: The method header contains an access modifier, the…
Q: Write the Author class with the required methods to give the following outputs as shown.
A: The program is written in Java. Please check step 2 for the program.
Q: What's the deal with the main method being static?
A: GIVEN: What's the deal with the main method being static?
Q: Tasks •Write a program to print the area of a rectangle by creating a class named 'Area' having two…
A: Since you are asking multiple questions, we are doing first question for you. If you want solution…
Q: Write a Temperature class that will hold a temperature in Fahrenheit, and provide methods to get the…
A: Actually, java is a object oriented programming language. It is a platform independent.
Q: Assume you have the following class that has all of those listed methods implemented for you.
A: Summary : - Hence we got the result.
TASK 5. Methods Overloading. Review Methods, Implement the following code, test it with different input, make sure it runs without errors.
Step by step
Solved in 5 steps with 5 images
- // SuperMarket.java - This program creates a report that lists weekly hours worked // by employees of a supermarket. The report lists total hours for // each day of one week. // Input: Interactive // Output: Report. import java.util.Scanner; public class SuperMarket { public static void main(String args[]) { // Declare variables. final String HEAD1 = "WEEKLY HOURS WORKED"; final String DAY_FOOTER = " Day Total "; // Leading spaces are intentional. final String SENTINEL = "done"; // Named constant for sentinel value. double hoursWorked = 0; // Current record hours. String hoursWorkedString = ""; // String version of hours String dayOfWeek; // Current record day of week. double hoursTotal = 0; // Hours total for a day. String prevDay = ""; // Previous day of week. boolean done = false; // loop control Scanner input = new…// Displays five random numbers between // (and including) user-specified values import java.util.Scanner; public class DebugSix4 { public static void main(String[] args) { int high, low, count = 0; final int NUM = 5; Scanner input = new Scanner(System.in); System.out.print("This application displays " + NUM + " random numbers" + "\nbetween the low and high values you enter" + "\nEnter low value now... "); low = input.nextInt() System.out.print("Enter high value... "); high = inputnextInt(); while(low < high) { System.out.println("The number you entered for a high number, " + high + ", is not more than " + low); System.out.print("Enter a number higher than " + low + "... "); high = input.nextInt(); while(count < NUM) { double result = Math.random(); int answer = (int) (result * 10 + low); if(answer <=…// ArtShow.java - This program determines if an art show attendee gets a 5% discount // for preregistering. // Input: Interactive. // Output: A statement telling the user if they get a discount or no discount. import java.util.Scanner; public class ArtShow { public static void main(String args[]) { Scanner s = new Scanner(System.in); String registerString; System.out.println("Did you preregister? Enter Y or N: "); registerString = s.nextLine(); // Test input here. If Y, call discount(), else call noDiscount(). System.exit(0); } // End of main() method. // Write discount method here. // Write noDiscount method here. } // End of ArtShow class.
- ** IT'S A JAVA DEBUGGING PROBLEM! // Application looks up home price // for different floor plans // allows upper or lowercase data entry import java.util.*; public class DebugEight3 { public static void main(String[] args) { Scanner input = new Scanner(System.in); String entry; char[] floorPlans = {'A','B','C','a','b','c'} int[] pricesInThousands = {145, 190, 235}; char plan; int x, fp = 99; String prompt = "Please select a floor plan\n" + "Our floorPlanss are:\n" + "A - Augusta, a ranch\n" + "B - Brittany, a split level\n" + "C - Colonial, a two-story\n" + "Enter floorPlans letter"; System.out.println(prompt); entry = input.next(); plan = entry.charAt(1); for(x = 0; x < floorPlans.length; ++x) if(plan == floorPlans[x]) x = fp; if(fp = 99) System.out.println("Invalid floor plan code entered")); else { if(fp >= 3)…13 public class MaxMinAtLeastOneValue 14 {. public static void main(String[] args) { Scanner in = new Scanner (System.in); 15 16 17 18 // Step 2: Read in an integer as the count of double values 19 wit an input prompt "Enter the count of values: and store it in a variable // 20 21 // 22 23 // Step 3: Read in a double value with an input prompt 24 25 "Enter the first value: and store it in a variable max 26 27 28 // Step 4: Assign the value of max to another 29 // variable min 30 31 32 // Step 5: Use a for loop to read all remaining double values with an input prompt 33 // 34 // "Enter the next value: 35 // and update max and min 36 37 saved// JumpinJive.java - This program looks up and prints the names and prices of coffee orders. // Input: Interactive. // Output: Name and price of coffee orders or error message if add-in is not found. import java.util.Scanner; public class JumpinJive { public static void main(String args[]) throws Exception { // Declare variables. String addIn; // Add-in ordered by customer. final int NUM_ITEMS = 5; // Named constant // Initialized array of add-ins. String addIns[] = {"Cream", "Cinnamon", "Chocolate", "Amaretto", "Whiskey"}; // Initialized array of add-in prices. double addInPrices[] = {.89, .25, .59, 1.50, 1.75}; boolean foundIt; int x; // Loop control variable. double orderTotal = 2.00; // All orders start with a 2.00 charge // Get user input. Scanner input = new Scanner(System.in); System.out.print("Enter coffee add-in or XXX to quit: "); addIn = input.nextLine();…
- // DebugFive4.java // Outputs highest of four numbers import java.util.*; public class DebugFive4 { publicstaticvoidmain (Stringargs[]) { Scanner input =newScanner(System.in); int one, two, three, four; String str, output; System.out.println("Enter an integer"); str = input.next(); one = Integer.parseInt(str); System.out.println("Enter an integer"); str = input.next(); two = Integer.parseInt(str); System.out.println("Enter an integer"); str = input.next(); three = Integer.parseInt(str); System.out.println("Enter an integer"); str = input.next(); four = Integer.parseInt(str); if(one > two > one > three > one > four) output = "Highest is " + four; else if(two > one && two > three !! two > four) output = "Highest is " + three; else if(three > one && three > two && three > four) output = "Highest is " + three; else output = "Highest is " + four; System.out.println(output); } }Print "userNum1 is negative." if userNum1 is less than 0. End with newline. Assign userNum2 with 4 if userNum2 is greater than 9. Otherwise, print "userNum2 is less than or equal to 9.". End with newline. 1 import java.util.Scanner; 2 public class UserNums { public static void main (String [] args) { int userNum1; int userNum2; 4 6. 7 Scanner input userNum1 = 8. = new Scanner(System.in); input.nextInt(); input.nextInt(); 9. 10 userNum2 11 12 V* Your code goes here */ 13 System.out.println("userNum2 is " } 14 + userNum2); 15 16 17 }// DebugFive2.java // Decides if two numbers are evenly divisible import java.util.Scanner; public class DebugFive2 { publicstaticvoidmain(Stringargs[]) { int num; int num2; Scanner input =newScanner(System.in); System.out.print("Enter a number "); num = input.nextInteger() System.out.print("Enter another number "); num2 = inputnextInt(); if((num % num2 ==0) && (num2 % num) ==0) System.out.println("One of these numbers is evenly divisible into the other"); else System.out.println("Neither of these numbers is evenly divisible into the other"); } }
- import java.util.Scanner ; //This program enables the user enters 10 int between -100 and 100 //then a menu is presented to the user to choose an operation to be //performed on the entered numbers. //operations: add all numbers and display their total //display the average of the numbers //find and display all negative numbers //find and display odd numbers //display all numbers in reverse order //display all 5 multiples public class OPonArrays { public static void main (String [] main) { int SIZE = 10; int [] nums= new int [SIZE]; Scanner KB = new Scanner(System.in); // populate the array for(int i = 0; i < 10; i++) { System.out.println("please enter a number between -100 and 100"); nums[i] = KB.nextInt(); } //display all elments for(int i = 0; i < 10; i++) { System .out.println(nums[i]); } fix the errorDebugEight4: Here is the code that needs to be debugged, I fixed some but it will not display the words in reverse at the end: // Application allows user to enter a series of words // and displays them in reverse order import java.util.*; public class DebugEight4 { public static void main(String[] args) { Scanner input = new Scanner(System.in); int x = 0, y; String array[] = new String[100]; String entry; final String STOP = "XXX"; StringBuffer message = new StringBuffer("The words in reverse order are\n"); System.out.println("Enter any word\n" + "Enter + STOP + when you want to stop"); entry = input.next(); while(!(entry.equals(STOP))) { array[x] = entry; ++x; System.out.println("Enter another word\n" + "Enter " + STOP + " when you want to stop"); entry = input.next(); } for(y = x - 1; y > 0; ++y) {…// FixedDebugFive04// Program prompts user for any number of values// (up to 20)// and averages them// C# Programusing System;public class DebugFive04{public static void Main(){int[] numbers = new int[20];const int QUIT = 999;int x;int num;double average;double total = 0;Console.Write("Please enter a number or " +QUIT + " to quit...");num = Convert.ToInt32(Console.ReadLine());x = 0;while ((x < numbers.Length) && num != QUIT){numbers[x] = num;total += numbers[x];Console.Write("Please enter a number or " +QUIT + " to quit...");num = Convert.ToInt32(Console.ReadLine());x++;}average = total / x;Console.WriteLine("The average is {0}", average);Console.WriteLine("The numbers are:");for (int y = 0; y < x; ++y)Console.Write("{0,6}", numbers[y]);}}