Question: Can someone please run this through Java and make sure I have done this correctly? I can't get #10 to return as a string but

Can someone please run this through Java and make sure I have done this correctly? I can't get #10 to return as a string but I would rather the code run without errors or at least be correct unless you can fix it. I will rate any helpful answers or answers with corrections to my code!

1.Write (define) a static method named displayGreeting, that takes no arguments and returns no value. When this function is called, it should print the text "Hello, and welcome!".

2.Write (define) a static method named displayText, that takes a single String argument and returns no value. When this function is called, it should print the value of the argument that was passed to it.

3.Write (define) a static method named printTotal, that takes three int arguments. When this function is called, it should print the sum of the three arguments passed to it. This function should return no value.

4.Write (define) a static method named getTotal, that takes three int arguments. When this function is called, it should return the sum of the three arguments passed to it as an int.

5.Write (define) a static method named getAverage, that takes three int arguments. When this function is called, it should return the average of the three arguments passed to it as a double

Code:

import java.util.*;

public class Assignment05 { public static void main(String[] args) { System.out.println("Dylan Zurfluh Assignment 5"); } // 1) Write (define) a static method named displayGreeting public static void displayGreeting() { System.out.print("Hello and welcome"); } //2) Write (define) a static method named displayText public static void displayText(String text) { //Print the output System.out.println("Value of argument: "+text); } //3) Write (define) a static method named printTotal public static void printTotal(int a, int b, int c) { System.out.println("Please enter the three values for your sum."); Scanner scan = new Scanner(System.in); int sum3; System.out.println("Value 1: "); a = scan.nextInt(); System.out.println("Value 2: "); b = scan.nextInt(); System.out.println("Value 3: "); c = scan.nextInt(); sum3 = a+b+c; System.out.println("The sum of your three numbers is: " + sum3); scan.close(); } //4) Write (define) a static method named getTotal public static double getTotal(int value1, int value2, int value3) { Scanner scan = new Scanner(System.in); System.out.println("Please enter the three values for your sum."); System.out.println("Value 1: "); value1 = scan.nextInt(); System.out.println("Value 2: "); value2 = scan.nextInt(); System.out.println("Value 3: "); value3 = scan.nextInt(); int sum4 = value1 + value2 + value3; return sum4; } //5) Write (define) a static method named getAverage public static double getAverage(int a, int b, int c){ Scanner scan = new Scanner(System.in); System.out.println("Please enter the three values for your average."); double average; System.out.println("Value 1: "); a = scan.nextInt(); System.out.println("Value 2: "); b = scan.nextInt(); System.out.println("Value 3: "); c = scan.nextInt(); average = (a+b+c)/3; return average; } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!