SampleTest Programming Techniques – Sample Practical Programming Test Questions The following questions are representative of the type of questions that you may be asked in the Practical Programming...

1 answer below »
Hi, This is not a assignment, it's an online test on Monday 18th Oct 2021, I am looking for someone who can solve my test question within 60 minutes of time. The test will be a simple java solution like simple reading a txt file, adding data into a txt file. it will not at all consume more time for experts in java. The procedure is I will send you the questions on my test day expert has to solve my question and send the java source file with in 60 mins to 65 mins


SampleTest Programming Techniques – Sample Practical Programming Test Questions The following questions are representative of the type of questions that you may be asked in the Practical Programming Test in Week 14. In the test you will be asked to create a Java Project and a number of class files (the name of the project and of the classes will be indicated at the time of the test) within Eclipse. At the end of the test you will create a ZIP file containing the project and java files. This ZIP will then be uploaded to vUWS for submission and marking. Depending upon the requirements of each question, the Test paper will typically contain two or three questions. Each question will have instructions similar to the following: Create a Class file called Question1_######## (where ######## is your student ID) as part of your Quiz project. At the top of the file include your Student ID, Name, Campus, Tutor Name and class number in the comments. In this file write a Java program to solve the following problem: Question # - X marks Write a Java program, using appropriate methods and parameter passing, that obtains from the user the following items: a person’s age, the person’s residential suburb, the person’s email address, and the person’s annual salary. The program should continue obtaining these details for as many people as the user wishes. As the data is obtained from the user • validate the age to ensure that the value lies in the range 20 to 30 inclusive; you may assume that the user will enter whole numbers only. • validate the salary to ensure that it lies in the range 40000 to 150000 inclusive; you may assume that the user will enter whole numbers only. • write the data to a text file named salaries.txt in the following format: age;suburb;email address;salary Note: each line of data represents one person and each data value is separated by a semicolon (;). Hence the data in the file that you create would look similar to: 28;Bondi;[email protected];65000 20;Westmead;[email protected];72000 26;Ryde;[email protected];81000 32;Glebe;[email protected];125000 When the program terminates, it should display to the screen the average salary of people 26 years old or older, and the average salary of people younger than 26 years old. Question # - X marks A file named loanBalance.txt contains numeric values that represent the balance of home loans for customers of a bank. The loan balance for each customer is on a separate line within the file. Example data from the file might be similar to: 265340.50 343892.00 238102.95 189820.75 406530.60 Your Java program must • read the file into an appropriate array – you may assume that the file exists. The array should be sized to store 500 loan balances but keep in mind that the file may not contain 500 loan balances. • after reading the file into the array, calculate and display the average (mean) of the loan balances from the array. • after reading the file into the array, determine and display the largest loan balance from the array. • use appropriate methods and parameter passing. Question # - X marks One way to estimate the adult height of a child (Hmale_child or Hfemale_child) is to use the following formula, which uses the height of the parents (Hmother and Hfather): Hmale_child = ((Hmother x 13/12) + Hfather)/2 Hfemale_child = ((Hfather x 12/13) + Hmother)/2 All heights in the formula are in inches. Write a Java program that takes as input the gender of the child, the height of the mother in inches, and the height of the father in inches, and outputs the estimated adult height of the child in inches. Write appropriate methods to obtain the height of the father, the height of the mother, the gender of the child, and that calculates the child’s estimated height. The height inputs are not allowed to be negative or zero but you may assume that whole numbers only will be input for the heights. Question # - X marks A file named customers.txt contains the names of customers for a local hairdressing salon. Unfortunately, the data in the file is in no particular order yet the owner of the salon would like the data in alphabetical order. Write a Java program that reads the contents of the file into an array of Strings, sorts the array of Strings into alphabetical order, and then writes the content of the array to a file named sortedCustomers.txt. customers.txt contains one name per line and may contain data similar to: Smith, Alexandra Downes, Trish Akbal, Maria Note the following: • You cannot assume how many lines of text are in the file. • You cannot assume that the file exists. • When storing the names in the array you may assume an array size of 500 elements. • When writing the names to the sortedCustomer.txt file there should be one name per line. For example: Akbal, Maria Downes, Trish Smith, Alexandra • Your code must use appropriate methods with parameter passing to solve the question. Question # - X marks Write a Java class that represents a Song from a music collection. The class needs to store data for the song title, the artist name, the duration (in minutes, eg a duration of 3.5 = 3 minutes and 30 seconds), and the rating (a numeric value indicating the current rating of the song by the user; values are whole numbers from 0 to 5). The class will need to have a constructor that takes a song title, artist name, duration, and rating as arguments, and a copy constructor. The class will need to have appropriate setter and getter methods as well as a toString method which is used to display the title and the rating of the song to the screen. Write a Java program that uses the Song class as described above. Write code in program that obtains the details for a song from the user, creates a new song object based upon that data, creates a copy of the object using the copy constructor, and then uses the toString method to show the contents of both objects created by the program. Study material/unitreviewstudentversion-3ydic0pp.pdf 12-1 Unit Content Summary — Review of unit material On each of the following slides I have written extra notes that you may wish to consider in preparation for the test in week 14. Please note that you should not just review the slides that I have included in this presentation – the slides included here are key aspects but will often require other reading from the relevant weeks lecture, textbook, and coding practice 1-2 An aside: variables When using variables in a program we need to consider ¡ how large that data value might be ÷ age ÷ population Is byte or short or int or long the best choice for these variables? byte = 1 byte = ints in range -128 to 127 short = 2 bytes = ints in range -32,768 to 32,767 int = 4 bytes = ints in range -2,147,483,648 to 2,147,483,647 long = 8 bytes = ints in range -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 (refer table 2.5, pp. 45) Week 1 Key: when creating your variables for any question please consider the most appropriate data type and size of that data type Using do-while to validate user input do{ System.out.print("enter length in cm "); length = kb.nextFloat(); if (length <= 0)="" {="" system.out.println("value="" must="" be=""> 0 "); System.out.print("enter length in cm "); length = kb.nextFloat(); } } while (length <= 0);="" system.out.print("enter="" conversion="" factor="" ");="" conversion="kb.nextFloat();" 2-3="" week="" 2="" key:="" validating="" user="" input="" should="" be="" second="" nature="" to="" you="" by="" now.="" make="" sure="" that="" you="" can="" implement="" it="" correctly="" using="" both="" do-while="" and="" while="" loop="" structures.="" implementing="" code="" like="" this="" within="" a="" question="" should="" not="" require="" you="" to="" look="" anything="" up="" in="" your="" textbook.="" if="" it="" does,="" then="" you="" are="" wasting="" valuable="" time="" in="" the="" test.="" using="" while="" to="" validate="" user="" input="" scanner="" kb="new" scanner(system.in);="" float="" length;="" float="" conversion;="" float="" convertedlength;="" system.out.print("enter="" length="" in="" cm="" ");="" length="kb.nextFloat();" while="" (length=""><= 0)="" {="" system.out.println("value="" must="" be=""> 0 "); System.out.print("enter length in cm "); length = kb.nextFloat(); } System.out.print("enter conversion factor "); conversion = kb.nextFloat(); convertedLength = length * conversion; System.out.println("Length in inches = " + convertedLength); Critical line? ‘Priming’ read 2-4 Week 2 Key: validating user input should be second nature to you by now. Make sure that you can implement it correctly using both do-while and while loop structures. Implementing code like this within a question should not require you to look anything up in your textbook. If it does, then you are wasting valuable time in the test. for loop Example problem Enter 10 numbers, counting the number of +ve numbers entered by a user. Solution : int number, count = 0; System.out.println("Enter 10 numbers."); for (int i = 0; i < 10;="" i++)="" {="" number="keyboard.nextInt();" if="" (number=""> 0) count++; } System.out.println("You entered " + count + " positive numbers"); 2-5 Week 2 Key: make sure you understand the mechanics of for loops and where they should be used and where they should not be used. Review the fact that each part of the for loop can have multiple variables, conditions etc Deciding Which Loop to Use — The while loop: ¡ Pretest loop ¡ Use it where you do not want the statements to execute if the condition is false in the beginning. — The do-while loop: ¡ Post-test loop ¡ Use it where you want the statements to execute at least once. — The for loop: ¡ Pretest & count controlled loop ¡ Use it where there is some type of counting variable that can be evaluated. 2-6 Week 2 Key: appropriateness of each loop structure to different problem types 3-7 Parts of a Method Header public static float validate(float value) { while (value <= 0)="" {="" system.out.print("error="" in="" input.="" must="" be=""> 0"); value = kb.nextFloat(); } return value; } Method Modifiers Return Type Method Name Parameters Chapter 5Week 3 Key: writing methods should
Answered 1 days AfterOct 16, 2021

Answer To: SampleTest Programming Techniques – Sample Practical Programming Test Questions The following...

Valupadasu answered on Oct 18 2021
118 Votes
test/.classpath

    
        
            
        
    
    
    
test/.project

     test
    
    
    
    
        
            
org.eclipse.jdt.core.javabuilder
            
            
        
    
    
        ...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here