Week 3 Assignment PDF

Title Week 3 Assignment
Author Debbie Dobbins
Course  Principles of Programming
Institution Walden University
Pages 17
File Size 366.8 KB
File Type PDF
Total Downloads 80
Total Views 174

Summary

Assignment Week 3 Assignment 1...


Description

Week 3: Assignment Application: Methods Methods are the next logical step in developing your skills as a programmer. Java provides the tools to perform certain tasks like adding numbers, accepting input and displaying output, and determining how many times to perform a set of commands. Methods provide the means to put all of these statements together into a succinct package that can be performed and reused, as necessary. In Chapter 5 of your textbook, you explore methods, how to create them, how to call them, how to pass information to them, and how methods can be structured to take that raw data and return useful information based on the statements and calculations that you develop. After you finish reading Chapter 5, test your comprehension of the material by completing all of the MyProgrammingLab problems for Chapter 5 as well as Programming Projects 73084 and 74085. To stay on schedule, complete the MyProgrammingLab materials for Chapter 5 no later than Day 7 of the week.

The Programming Projects for this week is 71109 & 71110 not Programming Projects 73084 and 74085.

Hello Dr. Casas, In the MyProgrammingLab I don’t see Programming Projects 73084 and 74085 under Chapter 5 Methods to complete Week 3 Assignment. The only Programming Projects for this week is 71109 & 71110. I will complete the Programming Projects under Chapter 5 71109 & 71110 just case this is a typo. Please provide instructions on where Programming Projects 73084 and 74085 are located. Thank You, Debbie

5. 1I nt r oduct i ont oMet hods Exer ci se20643 printTodaysDate is a method that accepts no arguments and returns no value. Write a statement that calls printTodaysDate. Assume that printTodaysDate is defined in the same class that calls it.

printTodaysDate();

Exer ci se20573 Write the code for invoking a method named sendSignal. There are no arguments for this method. Assume that sendSignal is defined in the same class that calls it.

sendSignal();

Exer ci se20651 Write the definition of a method printDottedLine, which has no parameters and doesn't return anything. The method prints to standard output a single line (terminated by a newline) consisting of five periods.

public static void printDottedLine (){ System.out.println("....."); }

5. 2Passi ngAr gument st oaMet hod Exer ci se20577 Write the code for invoking a method named sendObject. There is one argument for this method which is of type Customer. Assume that there is a reference to an object of type Customer, in a variable called John_Doe. Use this reference as your argument. Assume that sendObject is defined in the same class that calls it.

sendObject(John_Doe);

Exer ci se20652 Write the definition of a method printGrade, which has a char parameter and returns nothing. The method prints on a line by itself the messagestring Grade: followed by the char parameter (printed as a character) to standard output. Don't forget to put a new line character at the end of your line.

public static void printGrade(char x){ System.out.println("Grade: "+x); }

Exer ci se20653 Write the definition of a method printAttitude, which has an int parameter and returns nothing. The method prints a message to standard outputdepending on the value of its parameter.    

If the parameter equals 1, the method prints disagree If the parameter equals 2, the method prints no opinion If the parameter equals 3, the method prints agree In the case of other values, the method does nothing.

Each message is printed on a line by itself.

public static void printAttitude ( int x ){ if ( x == 1 ){ System.out.println ( "disagree" ) ; } if ( x == 2 ){ System.out.println ( "no opinion" ) ; } if ( x == 3 ){ System.out.println ( "agree" ) ; } }

Exer ci se20654 Write the definition of a method printLarger, which has two int parameters and returns nothing. The method prints the larger value of the two parameters to standard output on a single line by itself.

public static void printLarger (int x,int y){ int z = Math.max(x,y); System.out.println(z); }

Exer ci se20655 Write the definition of a method twice, which receives an integer parameter and returns an integer that is twice the value of the parameter.

public static int twice(int a){ int b=2*a; return b; }

Exer ci se20656 Write the definition of a method add, which receives two integer parameters and returns their sum.

public static int add(int arg1, int arg2) { return arg1+arg2; }

Exer ci se20657 Write the definition of a method dashedLine, with one parameter, an int. If the parameter is negative or zero, the method does nothing. Otherwise it prints a complete line terminated by a newline to standard outputconsisting of dashes (hyphens) with the parameter's value determining the number of dashes. The method returns nothing.

public void dashedLine (int a){ if (a>0){ int i; for (i=1;i...


Similar Free PDFs