Question

Define stubs for the methods called by the below main(). Each stub should print "FIXME: Finish...

Define stubs for the methods called by the below main(). Each stub should print "FIXME: Finish methodName()" followed by a newline, and should return -1. Example output:

FIXME: Finish getUserNum()
FIXME: Finish getUserNum()
FIXME: Finish computeAverage()
Avg: -1

import java.util.Scanner;

public class MethodStubs{

/* Your solution goes here */

public static void main(String [] args) {
int userNum1;
int userNum2;
int avgResult;
MethodStubs stubTester = new MethodStubs();

userNum1 = stubTester.getUserNum();
userNum2 = stubTester.getUserNum();
avgResult = stubTester.computeAverage(userNum1, userNum2);

System.out.println("Avg: " + avgResult);
}
}

1 0
Add a comment Improve this question Transcribed image text
✔ Recommended Answer
Answer #1

public class MethodStubs {

    

    public int getUserNum() {

        System.out.println("FIXME: Finish getUserNum()");

        return -1;

    }

    

    public int computeAverage(int n1, int n2) {

        System.out.println("FIXME: Finish computeAverage()");

        return -1;

    }

    

    public static void main(String[] args) {

        int userNum1;

        int userNum2;

        int avgResult;

        MethodStubs stubTester = new MethodStubs();

        

        userNum1 = stubTester.getUserNum();

        userNum2 = stubTester.getUserNum();

        avgResult = stubTester.computeAverage(userNum1, userNum2);

        

        System.out.println("Avg: " + avgResult);

    }

    

}


Add a comment
Know the answer?
Add Answer to:
Define stubs for the methods called by the below main(). Each stub should print "FIXME: Finish...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • THE LANGUAGE IS JAVA!! Define stubs for the methods called by the below main(). Each stub...

    THE LANGUAGE IS JAVA!! Define stubs for the methods called by the below main(). Each stub should print "FIXME: Finish methodName'followed by a newline, and should return -1. Example output: FIXME: Finish getUserNum() FIXME: Finish getUserNum() FIXME: Finish computeAvg() Avg: -1 import java.util.Scanner; 3 public class MthdStubsStatistics { 1* Your solution goes here */ public static void main(String [] args) { int userNum1; int userNum2; int avgResult; userNum1 = getUserNum(); userNum2 = getUserNum(); avgResult = computeAvg(userNumi, userNum2); System.out.println("Avg: " +...

  • All JAVA code 6.2.2: Define a method printFeetInchShort, with int parameters numFeet and numInches, that prints...

    All JAVA code 6.2.2: Define a method printFeetInchShort, with int parameters numFeet and numInches, that prints using ' and " shorthand. Ex: printFeetInchShort(5, 8) prints: 5' 8" Hint: Use \" to print a double quote Sample program: import java.util.Scanner; public class HeightPrinter { /* Your solution goes here */ public static void main (String [] args) { printFeetInchShort(5, 8); System.out.println(""); return; } } 6.4.1: Define stubs for the methods called by the below main(). Each stub should print "FIXME: Finish...

  • In C please Write a function so that the main() code below can be replaced by...

    In C please Write a function so that the main() code below can be replaced by the simpler code that calls function MphAndMinutesToMiles(). Original maino: int main(void) { double milesPerHour, double minutes Traveled; double hours Traveled; double miles Traveled; scanf("%f", &milesPerHour); scanf("%lf", &minutes Traveled); hours Traveled = minutes Traveled / 60.0; miles Traveled = hours Traveled * milesPerHour; printf("Miles: %1f\n", miles Traveled); return 0; 1 #include <stdio.h> 3/* Your solution goes here */ 1 test passed 4 All tests passed...

  • Answer in JAVA 1. Complete the method definition to output the hours given minutes. Output for...

    Answer in JAVA 1. Complete the method definition to output the hours given minutes. Output for sample program: 3.5 import java.util.Scanner; public class HourToMinConv {    public static void outputMinutesAsHours(double origMinutes) {       /* Your solution goes here */    }    public static void main (String [] args) {       Scanner scnr = new Scanner(System.in);       double minutes;       minutes = scnr.nextDouble();       outputMinutesAsHours(minutes); // Will be run with 210.0, 3600.0, and 0.0.       System.out.println("");    } } 2....

  • CHALLENGE ACTIVITY 3.11.1: Using boolean. D Assign is Teenager with true if kidAge is 13 to...

    CHALLENGE ACTIVITY 3.11.1: Using boolean. D Assign is Teenager with true if kidAge is 13 to 19 inclusive. Otherwise, assign is Teenager with false. 1 import java.util.Scanner; 3 public class TeenagerDetector 1 public static void main (String [] args) { Scanner scnr = new Scanner(System.in); boolean isTeenager; int kidAge; D}]oll kidage = scnr.nextInt(); /* Your solution goes here */ Go USB if (isTeenager) { System.out.println("Teen"); else { System.out.println("Not teen"); 20 Run Feedback? CHALLENGE ACTIVITY 3.11.2: Boolean in branching statements. Write...

  • Write a for loop to print all NUM_VALS elements of array hourlyTemp. Separate elements with a...

    Write a for loop to print all NUM_VALS elements of array hourlyTemp. Separate elements with a comma and space. Ex: If hourlyTemp = {90, 92, 94, 95}, print: 90, 92, 94, 95 Your code's output should end with the last element, without a subsequent comma, space, or newline. import java.util.Scanner; public class PrintWithComma {    public static void main (String [] args) {       Scanner scnr = new Scanner(System.in);       final int NUM_VALS = 4;       int[] hourlyTemp = new...

  • Write an if-else statement that checks patronAge. If 55 or greater print 'Senior citizen', otherwise print...

    Write an if-else statement that checks patronAge. If 55 or greater print 'Senior citizen', otherwise print 'Not senior citizen' (without quotes). End with newline. 1 import java.util.Scanner; Test pas public class DetectSenior public static void nain (String[] args) { Scanner sehr = new Scanner(System.in); int patronage; patronage - ser.nextInt(); * Your solution goes here */ 12 13 Write an if-else statement with multiple branches. If given Year is 2101 or greater print 'Distant future" (without quotes). Else, if given Year...

  • I wrote two java classes. One is main and other one is getter and setter. I...

    I wrote two java classes. One is main and other one is getter and setter. I brought methods from Digit class to Main class to print result. However, for some reason, only welcome print statement got printed and others got ignored. On the output screen, only welcome statement appear. nDigit should be input from user. import java.util.Scanner; public class Main {    public static void main(String[] args)    {        Digit digitGet = new Digit();              ...

  • CHALLENGE ACTIVITY 13.2.1: Functions: Factoring out a unit-conversion calculation Write a function so that the main...

     CHALLENGE ACTIVITY   13.2.1: Functions: Factoring out a unit-conversion calculation. Write a function so that the main 0 code below can be replaced by the simpler code that calls function MphAndMinutesToMiles 0 . Original main():13. 2.2: Function stubs: Statistics. Define stubs for the functions called by the below main0. Each stub should print "FIXME: Finish FunctionName0" followed by a newline, and should return -1. Example output:

  • In JAVA ACTIVITY 3.10.1: Rock-paper-scissors. Write a switch statement that checks nextChoice. If o print "Rock"....

    In JAVA ACTIVITY 3.10.1: Rock-paper-scissors. Write a switch statement that checks nextChoice. If o print "Rock". If 1 print "Paper". If 2 print "Scissors'. For any other value, print "Unknown'. End with newline. 2. 4 1 import java.util.Scanner; 3 public class Roshambo public static void main(String [] args) { 5 Scanner scnr - new Scanner(System.in); 6 int nextChoice; 7 8 nextChoice - scnr.nextInt(); 9 10 /" Your solution goes here */ 11 12 13} CHALLENGE ACTIVITY 3.10.2: Switch statement to...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT