Posts

Showing posts from June, 2017

Java Methods Design and Implementation

 /* This method will add the particular package to the DTHService  only if the package   is not present in the DTHService and return true. Otherwise return  false */ +findChannel(int channelId) throws ChannelNotFoundException:Channel  /* This method will check  if the particular channel is present  in the  existing list of packages in the DTHServices and   if found ,then  need to  return channel details  .Otherwise need to throw an exception- ChannelNotFoundException in the below format “The given channel is not found” +tagChannelToPackage(Package p,Channel c):String  /* This method will add the given  channel to the given  package  only if the  totalChannels tagged to that package is less than 5.And hence return “The channel ---- is  tagged to the package....”/. Otherwise display the message like “The channel cannot be tagged ” +findChannelRating(float rating):ArrayList<Channel>  /* Thi...

Student class with encapsulation concepts in Java | Buy Now!

Java Encapsulation Write a class encapsulating the concept of a Student, assuming that a student has the following attributes: last name, first name, id, array of 4 grades. Include a constructor, the accessors and mutators, and method toString. Also code the following methods: one returning the GPA using the array of grades (assuming each grade represents a course grade and all courses have the same number of credit hours) and a method to add a course grade to the array of grades (this means creating a larger array). Write a client class to test all your methods. Get Help Now!

Student class with encapsulation concepts in Java | Practice Quetsion

Java Encapsulation Write a class encapsulating the concept of a Student, assuming that a student has the following attributes: last name, first name, id, array of 4 grades. Include a constructor, the accessors and mutators, and method toString. Also code the following methods: one returning the GPA using the array of grades (assuming each grade represents a course grade and all courses have the same number of credit hours) and a method to add a course grade to the array of grades (this means creating a larger array). Write a client class to test all your methods. CONTACT DETAILS For any other questions or other tasks please feel free to contact me via email: mhassnainjamil@gmail.com via WhatsApp: +92-324-7042178 via skype: hassnainjamil1

Database Design, Entity Relationship Diagrams ERD and Tables

Pet Database Design ABC apartments has a one pet limit per apartment and they charge a nonrefundable deposit for the pet.  ABC wants to retain information about each pet and where it lives.  They do not allow a pet to be shared between apartments (in other words, a pet can’t live in different apartments).  So the rules for ABC are that an apartment may only have one pet and a pet may only live in one apartment.  Draw an ER Diagram for this model.  Then map you ER Diagram to a set of tables.  Be sure to include a reasonable set of attributes (ie. ApartmentNo, ApartmentBldg, PetID, PetName…) Recipe & Ingredients Database Design A recipe is made up of many ingredients but those ingredients may also be used in many different recipes.  Recipes have a have a recipe number, recipe name [and many other attributes which you do not need to show].  Ingredients have an Ingredient id and ingredient name [and many other attributes you do not need to show]. ...

Java Unit Test for RetailPriceCalculator class | Practice Question Solution

Assume a developer writes the following class that calculates an item's retail price based on the wholesale cost and markup percentage. Create a unit test to test this class. You may use the source code in any language, pseudo code, or natural language (statements). public class RetailPriceCalculator {     public static double calculateRetail(double wholesale, double markUp) {         double retail = wholesale * (1 + markUp / 100);         return retail;     } } CONTACT DETAILS For any other questions or other tasks please feel free to contact me via email: mhassnainjamil@gmail.com via WhatsApp: +92-324-7042178 via skype: hassnainjamil1

Java Unit Test for RetailPriceCalculator class | Practice Question

Assume a developer writes the following class that calculates an item's retail price based on the wholesale cost and markup percentage. Create a unit test to test this class. You may use the source code in any language, pseudo code, or natural language (statements). public class RetailPriceCalculator {     public static double calculateRetail(double wholesale, double markUp) {         double retail = wholesale * (1 + markUp / 100);         return retail;     } } CONTACT DETAILS For any other questions or other tasks please feel free to contact me via email: mhassnainjamil@gmail.com via WhatsApp: +92-324-7042178 via skype: hassnainjamil1

Relational Algebra, SQL and database design | Get complete solution now

Relational Algebra A database records information about athletes competing at the Olympics. An athlete competes for a particular country in one or more events. Events take place at a scheduled day and time in a particular venue. The result (rank) is recorded for all athletes in the final of the event. The medal (gold, silver or bronze) is also recorded for the medal winners in the event. Note that we are not considering team sports or heats in this example – only individuals competing in the finals. The schema for this database is as follows: (Note that primary keys are shown underlined, foreign keys in bold). ATHLETE ( AthleteNo , AthleteName, CountryName) COUNTRY ( CountryName , NumberOfCompetitors) EVENT (EventName, ScheduledStart, VenueName ) VENUE (VenueName, City, Capacity) FINAL ( AthleteNo , EventName , Rank, Medal) Provide relational algebra (NOT SQL) queries to find the following informaList the name and country of all athletes. List the event name and scheduled start time fo...

Pizza King Program in Java | Practice Questions

In main method, call the method performPizzaKingOperations. 1. orderPizza : This method will compare both orders, if they are same, even with different cases, then the method will throw a DuplicateOrderException 2. performPizzaKingOperations: This method takes parameters of pizza name that we want to order. For example Tomato , Capsicum, etc. Call orderPizza method from here. Exceptions should be handled in performPizzaKingOperations method only. This method should also be able to handle any other type of exceptions which are not known or declared. The performPizzaKingOperations method will execute for following scenarios depending on the 2 inputs provided and return an integer value as the result of execution. Everything works successfully for order names, for ex. Onion and Capsicum, then return 0 If both orders are same/duplicate , for example paneer and Paneer, and the DuplicateException was encountered then return -1 If any unknown exception occurs, then the result should be return...

Banking Application System with Exception Handling | Practice Questions

Banking System Description A banking system is looking for automated solution for managing accounts and related deposit and withdrawal. The system would currently support feature of Savings Account, however, it may have more account types in future. Develop a Java project which serves this system following below guidelines. Class outline is shared after the guidelines. Ensure the same is met 100%, else your solution would be considered null and void. Create project BankingSystem in eclipse. Create package com within src folder. All classes should be created inside this package. Create abstract class – Account with attributes account id, customer id and abstract methods – deposit and withdraw. Create child class – SavingAccount from this abstract class. This class will implement withdraw and deposit methods where amount to be deposited should be added to the balance and amount to be withdrawn should be deducted from the balance. Withdrawal will not check for zero balance, hence balance ...

Interface and Abstract Class in Java | Practice Questions

Write a program to calculate area of Circle by using getArea(int radius) method which is inherited from Shape and print the value by invoking that method from TestCircle class. Draw class diagrams for Shape,Circle and TestCircle. Write a program to calculate area of Rectangle by using getArea(int length,int width) method which is inherited from Shape and print the value by invoking that method from TestRectangle class. Draw class diagrams for Shape, Rectangle and TestRectangle. Write a program to calculate area of Square by using getArea(int length) method which is inherited from Shape and print the value by invoking that method from TestSquare class. Draw class diagrams for Shape, Square and TestSquare. Write a program to calculate the distance how much Kangaroo jumps by using jumping(double distance) method which is extended from Animal and print the value by invoking that method from TestKangaroo class. Draw class diagrams for Animal,Kangaroo and TestKangaroo. Write a program to cal...

Inheritance and Polymorphism in Java | Practice Question

Transportation A container terminal is a facility where cargo containers are transshipped between different transport vehicles, for onward transportation. The transshipment may be between container ships and land vehicles, for example trains or trucks, in which case the terminal is described as a maritime container terminal. Alternatively the transshipment may be between land vehicles, typically between train and truck, in which case the terminal is described as an inland container terminal. A terminal handles different types of containers like General purpose containers, Reefer Containers, Hazardous Container etc. Every container should mandatorily have Container number in the format XXXUNNNNNN9 where first three characters are owner code in alphabets, U - can be G - for general purpose, R for Reefer, H for Hazardous, 5th to 10th characters is serial number which is unique. Containers will have other attributes like ISO Code (String), Size (vaules can be 20, 40 or 45). Reefer Containe...

Exception Handling in Java | Practice Questions

Employee Registration Program Write a program for Employee registration process, take the employee details like empId, empName, age from user and register employee through addEmployee method, and throw the user defined exception like AgeMisMatchException, if the age of the employee is not greater than 18. Division Program Write a program for division of two numbers , class will take two numbers from key board and if numbers are not dividable then class throws ArithmaticException. Wrap the code in try catch block. Company Recruiting Program  Write a program for the below scenario. Company is recruiting the persons for one job opening, company has decided to take persons for the job only if the age is in between 22 and 35. if the person age is below 22 class should throw TooYoungException and if the person age is above 35 class should throw TooOldException. TooYoungException and TooOldExceptions are child classes of Age Exception. CONTACT DETAILS For any other questions or other task...

Client’s Problem Description | Learning/University Management System in Java

Problem Description  We were pleased with the initial design, and it helped us refine and further develop our requirements. Our main goal right now is supporting the student’s ability to take various courses while ensuring that they are also reasonably prepared for these courses in terms of background preparation. Also, we want to ensure that we have instructors to support these courses, while maintaining records of the courses that have been taught and taken. Therefore, we would like you to develop a prototype system that will read the input data, and then process the various student and instructor actions to maintain the proper system state. Input Data Files and Formats: Your system will need to read in data from six files: students.csv, courses.csv, instructors.csv, terms.csv, prereqs.csv and eligible.csv. Descriptions of these file formats are presented below. Also, the data in these files can (and likely will) change from test case to test case, so don’t assume that the data i...

Java Object Oriented Programming | Practice Questions

Sentence Processing Program Read three sentences from the console application. Each sentence should not exceed 80 characters. Then, copy each character in each input sentence in a [3 x 80] character array. The first sentence should be loaded into the first row in the reverse order of characters – for example, “mary had a little lamb” should be loaded into the array as “bmal elttil a dah yram”. The second sentence should be loaded into the second row in the reverse order of words – for example, “mary had a little lamb” should be loaded into the array as “lamb little a had mary”. The third sentence should be loaded into the third row where if the index of the array is divisible by 5, then the corresponding character is replaced by the letter ‘z’ – for example, “mary had a little lamb” should be loaded into the array as “mary zad azlittze lazb” – that is, characters in index positions 5, 10, 15, and 20 were replaced by ‘z’. Note that an empty space is also a character, and that the index ...

Object Oriented Programming | Practice Questions

Address Book Create a class named AddressBook that has the following field names: firstName middleName lastName homeAddress businessPhone homePhone cellphone skypeId facebookId personalWebSite. Use appropriate data types to store the values for these fields in AddressBook objects. Create appropriate get and set methods to retrieve and assign values to these names. For example, getMiddleName(viveAddressBook) should return the middle name of the person Vive. Similarly, vive.setPersonalWebsite(url) should set the personal website of the person Vive to the specified URL object. Using the get and set methods, create a comparison method compareNames(name1, name2) that compares the first, middle, and last names of strings name1 and name2. Assume that name1 and name2 follow the following format: “FirstName M. LastName”. Test your program for correct, partially correct (e.g., name string without the middleName), and incorrect inputs (e.g., phone number containing special characters). Employees ...

Java Unit Testing Practice | MyFax.java

Unit Testing Explain in this section here how unit test should be approached. Include in your discussion answers to the following questions: What are the goals and objectives for unit test? What are the key criteria for unit test to be complete – how do you know you are done unit testing? What kind of testing is unit test (black-box, white-box, boundary, etc.) and make sure to explain what that type of testing does? What are code coverage and data coverage and how they relate to unit test? What are test characteristics that you learned about in week 3 of this course? Name them and explain in your own words. Who normally writes and executes unit test? How do you determine that a defect has been found in UT? As defects are found during unit test who then fixes them? What happens next after defect is fixed in the code being tested? Be as complete and thorough in your discussion demonstrating your understanding of Unit Test. 100% Code Coverage Test Cases Test Case 1  Test case name: ...

Approximate Probabilistic Inference in Java with source code

Introduction The goal of this project is to implement in Java the rejection sampling and likelihood weighting approximate probabilistic inference approaches. Your software should be able to read a given Bayesian network consisting of binary variables from a text file in the following format: Cloudy, 0.5 Sprinkler, Cloudy, 0.1, 0.5 Rain, Cloudy, 0.8, 0.2 WetGrass, Sprinkler, Rain, 0.99, 0.09, 0.09, 0 Each line is a comma separated list of tokens that correspond to a variable of the Bayesian network. The name of the variable is given in the first token. Subsequent string tokens correspond to the parents of this variable. Subsequent numeric tokens give the probability that the variable of this line is true for all value combinations of its parents. In the above example, which corresponds to the sprinkler network from the book, for variable “Sprinkler”, the parent is the variable “Cloudy”, and the probability of Sprinkler=true is 0.1 if Cloudy=true and 0.5 if Cloudy=false. Your software s...

ATM Machine Project in Java | User Account | Deposit | Withdraw | Account Management

ATM Machine It would need to prompt the user for the balance at the beginning of the program and then present them with a list of options, Deposit, Withdraw, Check Balance and Exit. The program with loop and be able to do the math until exit. The program needs to use return values, methods, while loops if statements, and formatted outputs. CONTACT DETAILS For any other questions or other tasks please feel free to contact me via email: mhassnainjamil@gmail.com via WhatsApp: +92-324-7042178 via skype: hassnainjamil1

Relational Database, SQL and Database Design

Relational Algebra A database records information about athletes competing at the Olympics. An athlete competes for a particular country in one or more events. Events take place at a scheduled day and time in a particular venue. The result (rank) is recorded for all athletes in the final of the event. The medal (gold, silver or bronze) is also recorded for the medal winners in the event. Note that we are not considering team sports or heats in this example – only individuals competing in the finals. The schema for this database is as follows: (Note that primary keys are shown underlined, foreign keys in bold). ATHLETE ( AthleteNo , AthleteName, CountryName) COUNTRY ( CountryName , NumberOfCompetitors) EVENT (EventName, ScheduledStart, VenueName ) VENUE (VenueName, City, Capacity) FINAL ( AthleteNo , EventName , Rank, Medal) Provide relational algebra (NOT SQL) queries to find the following informaList the name and country of all athletes. List the event name and scheduled start time fo...

Arrays, Object and Classes Concepts in Java | Practice Questions

Trainee Class Methods Refer the below Class outline and implement the methods public boolean findTrainee(Trainee trainee[],int traineeId) public Trainee getTrainee(Trainee trainee[],int traineeId) public int getCount(Trainee trainee[],String location) public Trainee[] getAllTrainees(Trainee trainee[],String sequence) public int[] getAllId(Trainee trainee[]) Toy Class Create Class Toy with below attributes name  category  price discount Create Class ToyDemo with main method. Create four toy objects with relevant data. Two objects should have category as “fruits” and other two objects should have category as “animal”. Write a method in this class which will take all four toy objects as input. Additionally, it will also take category name as input. This method should return least price toy name (considering the discount as well) for specified category. If there is no specific category (e.g category as “fruits”, method should return message “no category found”. Follow class outli...

Array, Objects and Classes in Java | Practice Project

Customer Class Create class Connection with below attributes connId customerId customerEmail balance Create class ConnectionDemo with main method. Declare array of 3 Connection objects in mainmethod. Initialize this array where few objects have same customer id. Declare another methodin this class – getAverageBalance. This method will take the customer array and customer id asinput and return average balance for that customer. Display this average balance from mainmethod. Follow class outline diagram as given below. Ensure class attributes are private and othermethods are public. Use package “com” to build your solution. Student Class Create class Student with below attributes: rollNo Name Marks Create class StudentDemo with main method. Declare array of 5 student objects in mainmethod. Initialize this array. Declare another method in this class – splitStudentArray. Thismethod will take the student array and a character as input parameters. If the input character is‘o’ this method wi...