Question

Consider the method: private void ShowName(string firstName, string lastName) {           MessageBox.Show(firstName + “ ” + lastName);...

  1. Consider the method:
    private void ShowName(string firstName, string lastName) {           MessageBox.Show(firstName + “ ” + lastName);
    }

    Which of the following could be used to call the method?
  1. ShowName(lastName : “Smith”, firstName : “Suzanne”);
  2. ShowName(“Suzanne”, “Smith”);
  1. Write a method named showTax which has 2 parameters of type decimal. The first parameter is the price of the items sold. The second parameter is the tax rate which has a default value of 0.07. The method does not return a value. It multiplies the price by the tax rate and displays the result in a message box.
  2. Write a method named swap which will use 2 parameters of type double. It will have the parameters exchange values. For example, if the variables amt1 and amt2 have values 3.5 and 7.9 respectively, then after calling swap(amt1, amt2) the value of amt1 will be 7.9 and amt2 will be 3.5.

Please answer 2 and 3 using C# if you can. Thank you.

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

SOLUTION:- All answers are given below:-

=============================================================================================

Add a comment
Know the answer?
Add Answer to:
Consider the method: private void ShowName(string firstName, string lastName) {           MessageBox.Show(firstName + “ ” + lastName);...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Book: - title: String - price: double +Book() +Book(String, double) +getTitle(): String +setTitle(String): void +getPrice(): double...

    Book: - title: String - price: double +Book() +Book(String, double) +getTitle(): String +setTitle(String): void +getPrice(): double +setPrice(double): void +toString(): String The class has two attributes, title and price, and get/set methods for the two attributes. The first constructor doesn’t have a parameter. It assigns “” to title and 0.0 to price; The second constructor uses passed-in parameters to initialize the two attributes. The toString() method returns values for the two attributes. Notation: - means private, and + means public. 1....

  • ----------------------------------- public class Customer { String firstName,lastName; //constructor public Customer(String firstName,String lastName) { this.firstName=firstName; this.lastName=lastName; }...

    ----------------------------------- public class Customer { String firstName,lastName; //constructor public Customer(String firstName,String lastName) { this.firstName=firstName; this.lastName=lastName; } //override toString() method public String toString() { return this.lastName+", "+this.firstName; } boolean equals(Customer obj) { if(this.firstName.equals(obj.firstName) && this.lastName.equals(obj.lastName)) return true; else return false; } } ----------------------------------- public class Ingredient { String ingredientName; int amount; double price; public Ingredient(String ingredientName,int amount,double price) { this.ingredientName=ingredientName; this.amount=amount; this.price=price; } double getCost() { return amount/1000.0*price; } public String toString() { return this.ingredientName+", "+this.amount+" mls, $"+this.price+"/L"; } } -----------------------------------...

  • Create the Employee class: The Employee class has three attributes: private: string firstName; string lastName; string...

    Create the Employee class: The Employee class has three attributes: private: string firstName; string lastName; string SSN; The Employee class has ▪ a no-arg constructor (a no-arg contructor is a contructor with an empty parameter list): In this no-arg constructor, use “unknown” to initialize all private attributes. ▪ a constructor with parameters for each of the attributes ▪ getter and setter methods for each of the private attributes ▪ a method getFullName() that returns the last name, followed by a...

  • 3. Write Java methods to accomplish each of the following Write a method named simpleAry which...

    3. Write Java methods to accomplish each of the following Write a method named simpleAry which accepts and return nothing. It creates an array that can hold ten integers. Fill up each slot of the array with the number 113. Then, display the contents of the array on the screen. You must use a loop to put the values in the array and also to display them. Write a method named sury which accepts an array of type double with...

  • Write a console application that has/does the following • A method that uses a ref parameter...

    Write a console application that has/does the following • A method that uses a ref parameter for an integer. o Change the value of the ref parameter inside the method. • A method that has optional parameters. • A method that uses named arguments. • A Main method that has an integer variable with a value assigned to it. o Call the method that implements the ref parameter. o Print the value of the variable both before and after calling...

  • Additional info is this will use a total of four classes Book, BookApp, TextBook, and TextBookApp....

    Additional info is this will use a total of four classes Book, BookApp, TextBook, and TextBookApp. Also uses Super in the TextBook Class section. Problem 1 (10 points) Вook The left side diagram is a UML diagram for Book class. - title: String The class has two attributes, title and price, and get/set methods for the two attributes. - price: double Вook) Book(String, double) getTitle(): String setTitle(String): void + getPrice() double setPrice(double): void toString() String + The first constructor doesn't...

  • Consider a subroutine swap that takes two parameters and simply swaps their values. For example, after...

    Consider a subroutine swap that takes two parameters and simply swaps their values. For example, after calling swap(X,Y), X should have the original value of Y and Y the original value of X. Assume that variables to be swapped can be simple or subscripted (elements of an array), and they have the same type (integer). Show that it is impossible to write such a general-purpose swap subroutine in a language with: Parameter passing by name. Hint: for the case of...

  • Correct the mistakes public class customer { public static void main(String[] args) { D customer=new d();...

    Correct the mistakes public class customer { public static void main(String[] args) { D customer=new d(); d.employee(56,”ali”); d.department(7,8.6,9); } public void employee(String name, int age) { System.out.println("Your name is"+name); System.out.println(“Age is”+age); } public int department(double d, double t, int a) { System.out.println("I have java exam at 3:00"); Return(1.1); } } V. PROGRAMMING. Write a complete JAVA program to implement the following. 1. Create a class named Exponent. Its main() method accepts an integer value from a user at the keyboard,...

  • I need java code for the following problem. Lab 7: Methods 1. Write a Java program called Numbers that calls the following methods and displays the returned value: Write a method called cubelt that a...

    I need java code for the following problem. Lab 7: Methods 1. Write a Java program called Numbers that calls the following methods and displays the returned value: Write a method called cubelt that accepts one integer parameter and returns the value raised to the third power as an integer. o Write a method called randominRange that accepts two integer parameters representing a range. The method returns a random integer in the specified range inclusive. 2. o Write a method...

  • Lab 7: Methods 1. Write a Java program called Numbers that calls the following methods and...

    Lab 7: Methods 1. Write a Java program called Numbers that calls the following methods and displays the returned value: o Write a method called cubeIt that accepts one integer parameter and returns the value raised to the third power as an integer. 2. Write a method called randomInRange that accepts two integer parameters representing a range. The method returns a random integer in the specified range inclusive. o Write a method called larger that accepts two double parameters and...

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