Please answer 2 and 3 using C# if you can. Thank you.
SOLUTION:- All answers are given below:-


=============================================================================================
Consider the method: private void ShowName(string firstName, string lastName) { MessageBox.Show(firstName + “ ” + lastName);...
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;
}
//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 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 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 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.
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 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(); 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 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 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...