Java | JSP | JSF Answers

Questions: 4 418

Answers by our Experts: 3 943

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search & Filtering

Task 1: Username and Domain Name extraction [10 points]

Write a program that reads an email address from the keyboard. Assuming that the email address contains one at-sign (@) after the username, extract and print the username and the domain name of the email address.

 

Input: rayanas@oldwestbury.edu

 

Output:

Username: rayons

Domain name: oldwestbury.com

 

Task 2: Company name extraction from URL [10 points]

Write a program that reads a commercial website URL from the keyboard; you should expect that the URL starts with www, and ends with .com. Retrieve the name of the site, convert the first letter to uppercase to get the company name, and output it.

 

Input: www.yahoo.com

 

Output:

Company name: Yahoo

 

*use Scanner class to read a String as input from the keyboard for both the tasks. Check the following two lines of code for doing that.

 

Scanner scan = new Scanner(System.in);

String str = scan.next(); 



ProductRepository Contains an in memory list of products as an array Complete the class Product and ProductService as per the below requirement Class Product

Create the following properties. properties should be private -productCode : int name,String price double categoryString.Class ⦁ ProductService Define the below methods + findNameByCode(int): String - Should take product code as parameter and return the name of the product from the list of products present in ProductRepository If no product is found for the given product code, return null+findMaxPriceProduct(String): Product - Should take product category as a parameter and return the product object having the maximum price in the category provided. If no product is found for the given category, return null+ getProductsByCategory(String) : Product[] Should take product category as parameter and return the array of products in the category provided,If no product are found for the given category, return null



A teacher asked the class leader to prepare the list of  student details (name, Roll number, Branch and Sem) of his section by using read method and also to display the details of the students using java program


  • Create a folder named LastName_FirstName (ex. Reyes_Mark) in your local drive.
  • Create a project named LabExer2. Set the project location to your own folder.
  • Construct a simple purchasing program based on the UML Class Diagram below.

LabExer2

  • itemName: String
  • itemPrice: double
  • itemQuantity: int
  • amountDue: double

+ setItemName(String newItemName): void

+ setTotalCost (int quantity, double price): void

+ getItemName(): String

+ getTotalCost(): double

+ readInput(): void

+ writeOutput(): void

Note: The readInput() method will be used to accept user input through the Scanner class. This is done by:

  • Writing import java.util.*; on top of the code, before the line for the class name
  • Instantiating an object of the Scanner class, Scanner s = new Scanner (System.in);
  • Storing the input to the variable name based on data type For String: s.nextLine()

For int: s.nextInt()

For double: s.nextDouble()


You are purchasing 3 bag(s) at 1,745.5 each.


calculate the area of rectangle a square a triangle by using constructor overloading






Create another class called Television. Television is an Appliance. It only has the following additional private attributes:



type (whether Smart or Non-Smart)


volume (0 - 100)


channel (1 - 100)


It should have the following methods:



getters


void volumeUp() - increases the volume by 1 (possible only when TV is ON)


void volumeDown() - decreases the volume by 1 (possible only when TV is ON)


void channelUp() - increases the channel by 1 (possible only when TV is ON)


void channelDown() - decreases the channel by 1 (possible only when TV is ON)


String toString() - overriding Appliance's. It should include type, volume, and channel in this format ("Brand: xxxx, Cost: PhP xxxx.xx, Power: xx, Type: xxxx, Volume: xx, Channel: xx").




A lone constructor is to be implemented with a type, brand, and cost as an argument. It sets the volume to 0 and channel to 1. And it prints "Television Constructor" as well

Enter an integer: 20





20 plus 10 is 30.





20 plus 100 is 120.





20 plus 1000 is 1020.






Write a program that uses one or more if statements to solve the following problem:


Prompt the user for a number (type double) and the type of conversion calculation to apply. Once the user supplies the value and the type of conversion, your program should apply the appropriate conversion and display the result. For the conversion type, the user will enter one of the following conversion conversion codes: GL, IC, PK, MK.


Based on the user's input, your program will compute and display the appropriate result. See below for the meaning of the codes:


GL = Gallon to Liter

IC = Inch to Centimeter

PK = Pound to Kilogram

MK = Mile to Kilometer


For instance, if the user inputs GL as their conversion type, the program will then take their numeric input as gallons and converrt it to liters. The liters value would then be output to the user. Please find some additional information below to assist you in solving this problem:





Create a Java application that will Create a class called Team that will be used for creating team objects.

Data Members:

Name, HomeGround, and Goals.

Methods:

A default constructor which will initialize all data members to proper initial values

An overloaded constructor which receives two arguments; a team name and home ground name and it should also initialize the goals to a proper initial value

scoreGoals() should be 0 to 4 goals which will choose random number in that range

getName(), getHomeGround(), getGoals(), create get methods for each data member

In the main function use your classes to create object and demonstrate their functionality.

Create two team object prompt the user to enter the team name and the home ground name of each. Create Match object initializing it with the two team objects created above. Simulate play by calling the PlayMatch method of the Match object. Note that the isDrawMatch method should be called to determine if match is draw and display different output


A method called sine(), which takes as its only parameter a value of type double, and returns a value of type double. The parameter represents an angle expressed in radians, and the value returned by the method represents the trigonometric sine of this angle. For example, suppose the following method call is executed:

double sin = MyMath.sine(1.047197551);

After the execution of the above method call, the value stored in variable sin will be (approximately) 0.866025404, as the sine of 1.047197551 radians is approximately 0.866025404.


LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS