Find Us On: Facebook Twitter Rss Feed Blog
Need To Register? Sign Up Login

Java help examples

Ghost
Ghost 


HI i have a few question I was wondering if you can write a code i don't need a long code just a short code am trying to study for a test. So if you mind here they are. For a GML you can upload a picture. Please show your step and don't make them to long. 1. Given a program using classes, show the exact output that it will produce 2.Given a program using arrays, show the exact output that it will produce Questions continued… 3. Given a UML diagram of a class, a program using that class, and sample output, complete that class, including the definitions for the instance variables and the class methods which will involve generating random data (26) 4. Write a method that will accept an array as a parameter, process that array in some manner, and return a new array as a result Given one type of loop (for, while, do while), write the equivalent code using any of the other loop control statements Attachments
Tags Clarifications

Answers

Java Examples

SW_wizard
SW_wizard 



I have provided sample programs for all the 5 questions Attachments
JavaExamples.zip (62 K) Download
Preview
toString(){ //overrides toString() method of base class String str = super.toString(); //invokes toString() method of base class return (str

Preview
{ private String firstName; private String lastName; public Person(String fName, String lName){ firstName = fName; lastName = lName; }

Preview
lName; int ageOfCustomer; Scanner input = new Scanner(System.in); System.out.println("Enter first name of customer: "); fName = input.nextLine(); System.out.println("Enter last name of customer: "); lName = input.nextLine();

Preview
course); for(int i=0; i<marks.length; i++){ System.out.println("Marks in subject"+(i+1)+ ": " + marks[i]); } System.out.println("\n"); } void setMarks(int num){ System.out.println("Enter marks of "+ num + " subjects:"); Scanner input = new Scanner(System.in); for(int i=0; i<num; i++){ marks[i] = input.nextFloat();

Preview
//generate new employee id public static int getNextID(){ int id = nextID; nextID++; return id; } public static void main(String[] args) { Employee emp1 = new Employee("Jack"); //create employee object Employee emp2; String name; double

Preview

Preview
passed as argument public void displayArray(int[] arr){ for(int i=0; i<arr.length; i++){ System.out.print(arr[i] +" "); } } public static void main(String[] args) { TestArrays test = new TestArrays(); //initialize array1 & array2 int[] arr1 = {1,2,3,4};

Preview
24, 20, 18}; int total=0; //display marks array using for-loop System.out.println("Display marks of all subjects using for-loop"); for(int i=0; i<marks.length; i++){ System.out.println("subject "+(i+1)+": "+marks[i]); total = total + marks[i]; } System.out.println("Total marks: "+ total+"\n"); //display marks array using while-loop

Screenshots
Screenshot
Purchase Answer