Java Method Programming : Assignment

Added on - 21 Jul 2020

  • 15

    pages

  • 4930

    words

  • 6

    views

  • 0

    downloads

Showing pages 1 to 4 of 15 pages
ProgrammingTask 1a)Write a Java method to compute the average of five numbersimport java.util.Scanner;public class Avg5 {public static void main(String[] args) {Scanner in = new Scanner(System.in);System.out.print("Input first number: ");int num1 = in.nextInt();System.out.print("Input second number: ");int num2 = in.nextInt();System.out.print("Input third number: ");int num3 = in.nextInt();System.out.print("Input fourth number: ");int num4 = in.nextInt();System.out.print("Enter fifth number: ");int num5 = in.nextInt();System.out.println("Average of five numbers is: " +(num1 + num2 + num3 + num4 + num5) / 5);}}
b) Write a Java method to count all words in a string.import java.util.Scanner;public class wordcount {public static void main(String[] args){Scanner in = new Scanner(System.in);System.out.print("Input the string: ");String str = in.nextLine();System.out.print("Number of words in the string: " +count_Words(str)+"\n");}public static int count_Words(String str){int count = 0;if (!(" ".equals(str.substring(0, 1))) || !("".equals(str.substring(str.length() - 1)))){for (int i = 0; i < str.length(); i++){if (str.charAt(i) == ' '){count++;}}count = count + 1;}return count; // returns 0 if string starts or endswith space " ".}}
Task 2Class DiagramEmployee Table related to depart table.Department table related to Company table.Project table is related to company tables.
Task 3a)In a maximum of 500 words, critically evaluate the principles of object oriented programming.Today, object oriented programming will probably be the predominant programming paradigm as wellas Java is completely subject targeted. In addition, Java has become the various used language amongstTHAT service providers. Therefore, scholars often learn Java and subject oriented programming (OOP)actually introductory courses. This permits a perfect basis for a “later introduction to other paradigmswhich includes logical or useful coding. Moreover, OOP helps introducing students to ideas very muchlike specification construction, resistant and also.These techniques start by showing items, interfaces, classes and also features from the beginning, e. l.the Outside-In teaching way of OOP based on the programming vocab Eiffel. Problem Statement:Irrespective of several lecturers having simply by present used the Outside-In teaching approach in theirlessons, little research evidence upon its outcomes dominates. A lot of authors looked simply by thescheduled program action connected with involved students, nevertheless influence on learning effectsas well as enthusiasm and fascination has not been recently researched to date. Research Objective:Educating OO rules to apprentices is usually a great important task of program engineering education.Consequently , with this paper the feasibility as well as effects of employing Outside-In educating forcoaching OOP in a matter of university-level initial courses making use of Java will be empirically lookedat. In particular, the aim was to realize its influence on learning positive components in addition, oninterest and ideas in the participants. Context: We all considered Outside-In teaching in suite an suite intwo opening classes for computer scientific exploration and OOP (Bachelor level, 1st year) at a set ofGerman universities in the winter period 2012/13. The courses have already been Programming andSoftware Development (PSD) at the University associated with Stuttgart (Stuttgart) and DevelopmentTechnique from the study course “Information Management Automotive” (IMA) at the Institution ofModern developments Neu-Ulm (Ulm).The major challenge was the replacement of Eiffel just by Java. Eiffel is more patristic in its object-oriented constructs compared to Java. For example, for Caffeine an early introduction of long termmethods is necessary because the strategy is executed with the everlasting key method. The basicprinciple of carrying out a program in Eiffel will probably be considerably easier. Compared to Eiffel, Javalacks an area support for contracts, added tools have to be applied as a result. Regarding the scope, thetwo classes at Ulm and Stuttgart distinctly are different. Programming as well as Computer programsDevelopment (PSD) with Stuttgart consists of four several hours lecture and two occasions tutorials withteaching colleagues per week. Programming Strategy inside Ulm consists of two a large number of hourslecture and two period lecturer-guided tutorials. Furthermore, only two additional several hours ofencouraged tutorial each week are offered. Several topics just like the setup as well as the functionalrule of a personal computer system or perhaps data structures are generally products of separateaddress classes at Ulm. That is why, these types of units are not included right here. Thus, compared toUlm, for Stuttgart much more issues will be examined during a session. PSD at Stuttgart resembles agreat introduction to computer engineering.
desklib-logo
You’re reading a preview
card-image

To View Complete Document

Become a Desklib Library Member.
Subscribe to our plans

Download This Document