Jump to content

Is there any intelligent person in the Java programming? plz

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
9 replies to this topic

#1
alaseier

alaseier

    Newbie

  • Members
  • Pip
  • 5 posts
Please help me to solve this: (
Only three questions....



The questions given below are based on the lecture notes, and are intended to familiarize you with concepts of arrays, ArrayList and inheritance.


1. Arrays
Write a program that read in 16 values from the keyboard and store them into a two dimension array (myArray). The program then calculate the sum of every row elements and every column elements an put this sum into elements of two arrays (one for the rows – rowSum and the other for columns- colSum ) ,then the program print the three arrays.



2. ArrayList class

You are to write a simple names book program. A names book contains names of your friends. Store your names book as an ArrayList with entries contains strings that represent the names. Your program must tell you how many friends you have and which one of them has the longest name.


3. Inheritance

Design and draw the UML class diagram of a set of classes that define the employees of a Hospital, the classes are:
HospitalPerson , Doctor and Nurse.
Where HospitalPerson is a supper class, Doctor and Nurse are subclasses.

Design your classes to satisfy the following requirements:
1. Each HospitalPerson has a name and an idNumber.
2. A Doctor has in addition a specialty attribute, while a Nurse has a
maxDutyHours attribute.
3. We want to have a special print (output information) as following:
a. The name and idNumber of a HospitalPerson works for the Hospital.
b. The specialty of a Doctor.
c. The maxDutyHours of a Nurse.

## The paper found attachments

#2
Sinipull

Sinipull

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 386 posts
We will help you with any questions, but we will not complete your homework.
the ONLY way to learn programming is to program.

#3
alaseier

alaseier

    Newbie

  • Members
  • Pip
  • 5 posts
only 1st

I want help my brother that not for me.

#4
isuru

isuru

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 233 posts
I am so sorry. You must first try. Then post that code here. Then we will help you if that code got any problems,. Official Java Tutorial help you if you are not familiar with java. I know a person who learned lot of basic within two days. Try your-self.

#5
alaseier

alaseier

    Newbie

  • Members
  • Pip
  • 5 posts
public class Primes
{

public static void main (String[] args)
{
int[] myArray = {2, 3, 5, 7, 11, 13, 17, 19};

System.out.println ("Array length: " + myArray.length);

System.out.println ("The first few prime numbers are:");

for (int scan = 0; scan < myArray.length; scan++)
System.out.print (primeNums[scan] + " ");

System.out.println ();
}
}






is right????

#6
TIT

TIT

    Newbie

  • Members
  • Pip
  • 2 posts
Have you tried It out if it does what it says on the tin then it's right.
I'm new to this myself so little of that means anything to me I'm more proficient with unity's native java sorry.
I hope it's right. though looking at it i feel the pattern is wrong but hey i'm no expert.
best of luck with your assignment.:P

#7
tate

tate

    Learning Programmer

  • Members
  • PipPipPip
  • 90 posts
Um you will probably need to change the line:
System.out.print (primeNums[scan] + "  ");
to:
System.out.print (myArray[scan] + "  ");
for it to compile and run.
twas brillig

#8
agnl666

agnl666

    Programmer

  • Members
  • PipPipPipPip
  • 173 posts
the code that you were asking if it was write didn't look like it had anything to do with the three first problem you were asking about ? do you still want to know about the first three problems ?

#9
alaseier

alaseier

    Newbie

  • Members
  • Pip
  • 5 posts
help me plz : (

#10
alaseier

alaseier

    Newbie

  • Members
  • Pip
  • 5 posts
import java.util.Scanner;


public class TowDArray{
public static void main(String[] args){

int[][] myArray=new int[4][4];
Scanner in=new Scanner(System.in);
System.out.println("ENTER THE NUMBER");

for(int row=0; row<myArray.length; row++)
for(int col=0; col<[row].length; col++)
myArray[row]=in.nextInt();
myArray[col]=in.nextInt();

for(int row=0; row<myArray.length; row++)
for(int col=0; col<[row].length; col++)
System.out.println(myArray[row][col]);

int b=0;
int[] rowSum=new int[4];
for(int row=0; row<rowSum.length; row++)
rowSum[row]=rowSum[row]+b;
System.out.println("THE ROWS SUM :");
System.out.println(rowSum[row]);

int[] colSum=new int[4];
for(int col=0; col<colSum.length; col++)
colSum[col]=colSum[col]+b;
System.out.println("THE COLUMNS SUM :");
System.out.println(colSum[col]);
}
}--------------------------------

tell me of now is rigth.