Java | JSP | JSF Answers

Questions: 3 611

Answers by our Experts: 3 611

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

 consider 3 possible scenarios of input: A character, number, or word. Your program should then do the following:

  • In case the input is a character it should indicate if it’s a vowel or not
  • when a number is entered then it’s should check if it’s a prime
  • Finally, if a word is entered the system should check if it’s a palindrome or not.

. Create a program in java that takes in an input from the user and checks whether it’s a number or a word. In case a number is entered the program should print the number to the power 3 and if a word is entered your program should split that word into 2.


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(); 



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


LATEST TUTORIALS
APPROVED BY CLIENTS