Subjects
PRICING
COURSES
SIGN IN
Start Free Trial
Salil B.
Freelance Tutor and Software Professional
Tutor Satisfaction Guarantee
Java Programming
TutorMe
Question:

Code a program that prompts the user for the size of the array. Using the size, the program creates several arrays that will store information about your family. There will be one array for all your family member's names, another for their roles, and the last one for their ages. The values in each array at the same location are for a given family member. Once the arrays are populated, print the information from each array. The size and input will be the only class variables. Use printf(). Code your program according to the specifications below. Use the looping structure generally associated with array processing. Name the program YourLastNameFirstInitialLE62.java. The methods will be called from the main(). 1st Input Prompt: Code this in a method named arraySize(). How many family members in your immediate family including yourself? 2nd Input Prompt: In a method named setNames declare the familyNames array and populate it. This method will return the familyName array to the calling statement. The 9 in the prompt below will print 1 for the first family member, then 2 for the 2nd one and so forth. Use the loop-control variable as the value for 9. Enter family member 9: 3rd Input Prompt: In a method named setRoles declare the familyRoles array and populate it. The Xs in the prompt is the name of the family member. The setRoles method will return the familyRoles array to the calling statement as well as receive the familyNames array from the calling statement. This method will be called as an argument in the call to printFamilyInfo(). What relationship is Xxxxxxxxxx to you? 4th Input Prompt: In a method named setAges declare the familyAges array and populate it. The Xs in the prompt is the name of the family member. The setAges method will return the familyAges array to the calling statement as well as receive the familyNames array from the calling statement. setAges() will be called as an argument in the call to printFamilyInfo(). How old is Xxxxxxxxxx? Output Specifications: Where the Xs represent the family member's name and role and the Zs the age. Code the output print statement in a method named printFamilyInfo() that accepts the familyNames, familyRoles, and familyAges arrays. In the printFamilyInfo method use a for loop to print the information for each family member from each array. The print for the header has to be outside of the for loop because it's printed only once. MY FAMILY Name: Xxxxxxxxxx Role: Xxxxxxxxxx Age: ZZ9 Name: Xxxxxxxxxx Role: Xxxxxxxxxx Age: ZZ9 Here is the sample OUTPUT: How many family members in your immediate family including yourself? 4 Enter family member 1: Fred Enter family member 2: Wilma Enter family member 3: Pebbles Enter family member 4: Bambam What relationship is Fred to you? Father What relationship is Wilma to you? Self What relationship is Bambam to you? Brother How old is Fred? 45 How old is Wilma? 43 How old is Pebbles? 18 How old is Bambam? 15 MY FAMILY Name: Fred Role: Father Age: 45 Name: Wilma Role: Mother Age: 43 Name: Pebbles Role: Self Age: 18 Name: Bambam Role: Brother Age: 15

Salil B.
Answer:

Below is your code. Let me know if you have any issue in comments.,... YourLastNameFirstInitialLE62.java import java.util.Scanner; public class YourLastNameFirstInitialLE62 { public static int arraySize(Scanner inp) { System.out.printf("How many family members in your immediate family including yourself?"); return Integer.parseInt(inp.next()); } public static String[] setNames(int size, Scanner sc) { String[] familyNames = new String[size]; for (int i = 0; i < size; i++) { System.out.printf("Enter family member %d : ", (i + 1)); familyNames[i] = sc.next(); } return familyNames; } public static String[] setRoles(String[] familyNames, Scanner sc) { String[] familyRoles = new String[familyNames.length]; for (int i = 0; i < familyNames.length; i++) { System.out.printf("What relationship is %s to you? ", familyNames[i]); familyRoles[i] = sc.next(); } return familyRoles; } public static Integer[] setAges(String[] familyNames, Scanner sc) { Integer[] familyAges = new Integer[familyNames.length]; for (int i = 0; i < familyNames.length; i++) { System.out.printf("How old is %s? ", familyNames[i]); familyAges[i] = Integer.parseInt(sc.next()); } return familyAges; } public static void printFamilyInfo(String[] familyNames, String[] familyRoles, Integer[] familyAges) { System.out.printf("\nMY FAMILY\n"); for (int i = 0; i < familyNames.length; i++) { System.out.printf("\nName: %s", familyNames[i]); System.out.printf("\nRole: %s", familyRoles[i]); System.out.printf("\nAge: %d", familyAges[i]); } } public static void main(String[] args) { Scanner sc = new Scanner(System.in); int size = arraySize(sc); String[] familyNames = setNames(size, sc); printFamilyInfo(familyNames, setRoles(familyNames, sc), setAges(familyNames, sc)); } } Sample Run: - How many family members in your immediate family including yourself?4 Enter family member 1 : Fred Enter family member 2 : Wilma Enter family member 3 : Pebbles Enter family member 4 : Bambam What relationship is Fred to you? Father What relationship is Wilma to you? Mother What relationship is Pebbles to you? Self What relationship is Bambam to you? Brother How old is Fred? 44 How old is Wilma? 42 How old is Pebbles? 23 How old is Bambam? 21 MY FAMILY Name: Fred Role: Father Age: 44 Name: Wilma Role: Mother Age: 42 Name: Pebbles Role: Self Age: 23 Name: Bambam Role: Brother Age: 21

Computer Science (General)
TutorMe
Question:

Let us say your company has a collection of identical Web servers to handle incoming Web transactions. How would you distribute the incoming processing requests?

Salil B.
Answer:

If we have a set of identical web servers, the set of those web servers can be combined to create a logical combination called web farm. In general, web farm is a collection of web servers maintained by enterprise to process multiple client requests efficiently which are far beyond single web server capability. In this architecture, single application is hosted on multiple servers which are connected with each other using Load Balancer. Load Balancer is the main hardware between the client request and the collection of web servers. They distribute the incoming processing requests to the servers in some predefined way for eg. Round Robin etc. The load balancer also provides required level of redundancy, so that, if one server fails, the request should still get processed thus increasing the reliability and uptime of the application. There are various ways in which different requests are distributed by load balancers: - 1.Even Task Distribution Scheme Here the tasks are distributed equally amonth the web servers. eg. Round Robin. 2. Weighted Task Distribution Scheme In this type of distribution, weights are assigned to the tasks and each server has particular weight threshhold which means the maxiumum weighted tasks it can manage. So in this way the tasks are distrubuted. These are the main two types. Other few types which are used while request distreibution are: - a) Sticky Session Scheme b) Even Size Task Queue Distribution Scheme c) Autonomous Queue Scheme

C++ Programming
TutorMe
Question:

C++ -- Write a function called Median that has two parameters - an array of int and the size of the array. This function will return the median of the array, which will require sorting the array. For this assignment , it is okay to change the original array,. Do not test your code by calling it by calling it from a different file. The file must be named: Median.cpp.

Salil B.
Answer:

Below is your code. As per your question , what I understood is that you want the code(method median) to be tested in same file of the code. Let me know in comments if you have any issue: - #include <iostream> using namespace std; void sort(int *num,int n) { for(int i=0; i<=n; i++) { for(int j=i+1; j<=n; j++) { if(num[i]<num[j]) { int temp=num[j]; num[j]=num[i]; num[i]=temp; } } } } float Median(int *mArray,int n) { sort(mArray,n); float median; int middlel; switch(n%2) { // n starts from 0 so adding 1 case(0): // even middlel = (n/2) - 1; median = (mArray[middlel] + mArray[middlel+1])/(float)2; break; case(1): // odd middlel = (n/2); median = mArray[middlel]; break; } return median; } int main() { int iArray[] = {2,10,5,1,55,7,48,103,22,6,3,99,45,99}; // LoL, as random as I can think of em. int size = sizeof(iArray)/sizeof(iArray[0]); cout << "Median is: " << Median(iArray,size) << endl; return 0; }

Send a message explaining your
needs and Salil will reply soon.
Contact Salil
Ready now? Request a lesson.
Start Session
FAQs
What is a lesson?
A lesson is virtual lesson space on our platform where you and a tutor can communicate. You'll have the option to communicate using video/audio as well as text chat. You can also upload documents, edit papers in real time and use our cutting-edge virtual whiteboard.
How do I begin a lesson?
If the tutor is currently online, you can click the "Start Session" button above. If they are offline, you can always send them a message to schedule a lesson.
Who are TutorMe tutors?
Many of our tutors are current college students or recent graduates of top-tier universities like MIT, Harvard and USC. TutorMe has thousands of top-quality tutors available to work with you.