Questions
(JAVA) Create a program that creates a mini database of numbers that allows the user to:...

(JAVA)

Create a program that creates a mini database of numbers that allows the user to: reset the database, print the database, add a number to the database, find the sum of the elements in the database, or quit.

In main, you will declare an array of 10 integers (this is a requirement). Then you will define the following methods: • printArray (int[ ] arr) – this takes in an array and prints it • initArray (int[ ] arr) – this initializes the array so that each cell is 0 • printSum (int[ ] arr) – this calculates the sum of the elements in the array and prints it • enterNum(int[ ] arr) – this asks the user for a slot number and value – putting the value into the array in the correct slot • printMenu (int[ ] arr) – prints the menu in the sample output (that’s it, nothing more)

In main, create an array of 10 integers and immediately call initArray( ). Then, continuously looping, print the menu and ask the user what they want to do – calling the appropriate methods based on the user’s choice. Note that every time you call a method, you must pass the array that was created in main. If it makes it easier, we used a do-while loop and a switch statement in main.

It should behave like the sample output below: (user input = bold)

Would you like to:

1) Enter a number

2) Print the array

3) Find the sum of the array

4) Reset the array

5) Quit

1

Enter the slot: 5

Enter the new value: 76

Would you like to:

1) Enter a number

2) Print the array

3) Find the sum of the array

4) Reset the array

5) Quit

1

Enter the slot: 2

Enter the new value: 33

Would you like to:

1) Enter a number

2) Print the array

3) Find the sum of the array

4) Reset the array

5) Quit

2

|0|0|33|0|0|76|0|0|0|0

Would you like to:

1) Enter a number

2) Print the array

3) Find the sum of the array

4) Reset the array

5) Quit

3

109

Would you like to:

1) Enter a number

2) Print the array

3) Find the sum of the array

4) Reset the array

5) Quit

4

Would you like to:

1) Enter a number

2) Print the array

3) Find the sum of the array

4) Reset the array

5) Quit

2

|0|0|0|0|0|0|0|0|0|0

Would you like to:

1) Enter a number

2) Print the array

3) Find the sum of the array

4) Reset the array

5) Quit

5

In: Computer Science

you are givena pair (a,b) .after eatch unit of time pair(a,b) getd changeed to (b-a,b+a).you are...

you are givena pair (a,b) .after eatch unit of time pair(a,b)
getd changeed to (b-a,b+a).you are given the initial value of
pair and an integer n and you have to print the value of the pair at the nth unit of time

In: Computer Science

Analyse the security of Lamport’s OLP algorithm with the properties of hash function.

Analyse the security of Lamport’s OLP algorithm with the properties of hash function.

In: Computer Science

By using javaFX, write and design the Towers of Hanoi game with Redo and Undo features...

By using javaFX, write and design the Towers of Hanoi game with Redo and Undo features with play and solve options.

In: Computer Science

Please write with structure, not class! Add comments for clear understanding. Write code without using scope...

Please write with structure, not class! Add comments for clear understanding. Write code without using scope resolution operators.

Write an ADT to represent a doctor's medical registration number (a non-negative integer), number of patients (a non-negative integer), and income (non-negative, in euros).
A doctor's information should be represented by a structure with 3 fields: medical_reg and num_patients of type int, and income of type float.
Your ADT should define four interface functions to carry out the following operations:

· Construct a new doctor, given input arguments for medical registration number, number of patients, and income. This function should not do any error-checking on its inputs.
· Print out to the screen the values of medical registration number, number of patients, and income for a specified doctor.
· Add two doctors to return a new ‘doctor' by adding the values of the corresponding number of patients and income fields, inserting a dummy value for the medical registration number of the new ‘doctor'. A dummy value is something that could not be a valid value; you must decide what an appropriate dummy value is in this case.
· Compare 2 doctors to determine which of them is "greater", according to these rules: the doctor with the higher income is greater; if the 2 doctors have the same income, the doctor with more patients is greater; if both income and number of patients are the same, the 2 doctors are equal. This function does not return a value, but prints out the values for the "greater" doctor or that the doctors are equal, as appropriate.

Write a main function which tests each aspect of your work:
ask the user for the values of medical registration number, number of patients, and income for 2 doctors;
print out each doctor's values;
then print out the values for the addition of these 2 doctors, and determine which of them (if either) is "greater".
You may assume that the user enters valid values for each doctor's fields from the keyboard.

So you should write three files:
· A header file to hold the structure definition and the prototypes of the interface functions
· A C++ source file to hold the implementations of the interface functions
· Another C++ source file to hold the main program

In: Computer Science

Mr. Kent doesn't care about almost anything ... but himself and his money. So, when his...

Mr. Kent doesn't care about almost anything ... but himself and his money. So, when his power plant leaked radioactive goo that caused several species of wildlife to go extinct, he was only concerned with the public perception as it might affect his income and possible jail time.

Many rumors surfaced around the Springfield Nuclear Power Plant. One of them is high concern over the mutation rate of the rare Springfield molted platypus. With barely more than 500 left in the wild, the word "extinction" has been tossed around. So, to quell the media, Mr. Kent had 30 of them captured, dissected, and analyzed to check for signs of mutation. He found that the mutation rate is 2% each month, but when they do mutate, they become sterile and cannot reproduce. With this information, he wants to create one of those newfangled computer simulations that the press loves so much. That's where you come in!

Specifications:

In this assignment, you will create a class called Animal_Category.

Your Animal_Category class is to contain the following data members:

  • A string for appearance ( hair/fur/scale/feathers)
  • a bool for nurse (true/false)
  • a bool for cold_blooded (true/false)
  • a bool for live_on_land (true/false)
  • a bool for live_in_water (true/false)

Your Animal_Category class is to contain the following member functions:

  • a constructor with arguments
  • a print function

You will also create a class called Platypus. Below, we will describe what will define a platypus. You will also create a main function in which you will create objects of type platypus to test the functionality of your new user-defined type.

Your Platypus class is to contain the following data members:

  • a static int for platypus_count (to increment upon creation of a new platypus and decrement upon destruction of a platypus)
  • a float for weight
  • an int for age (months)
  • a string for name
  • a char for gender
  • a bool to indicate whether alive (or not)
  • a bool to indicate whether mutant (or not)
  • an Animal_Category for animal_type
  • a constant mutation rate that is 2%

Member functions:

  • a constructor with no arguments that creates a dead platypus
  • a constructor that you can pass values to so as to establish its gender, weight, age, and name; it will default to alive and not mutant.
  • a constant print function that will output to the screen the attributes of that platypus in a nice, easy to read format.
  • an age_me function that returns nothing but increments the object's age. It will also calculate the chance that the object will become a mutant and when needed changes the value of the corresponding data member (remember that the mutation rate is 2% each month and it should become 100% for the platypus to become mutant).

Further, the platypus has a chance of becoming dead each time it ages. This chance is ten times the platypus' weight. A 5 pound platypus has a 50% chance of death. A 10 pound platypus (or heavier) has a 100% chance of death. Again here update the value of the corresponding data member when needed.

  • a fight function that accepts another platypus object as a parameter. It will have the calling platypus attack the other (passed in) platypus. The survivor is based on a "fight ratio": it is calculated as (calling_platypus_weight/other_platypus_weight) * 50. A random value from 1 to 100 is generated. If it is less than the fight ratio, the calling platypus survives; otherwise the other platypus survives. You must to be able to have a statement like p1.fight(p2).print() (where p1 and p2 are objects of this class)
  • an eat function that increases the weight of the platypus by a random amount from 0.1% to 5.0% of the platypus' current weight.
  • A friend hatch function that will randomly set up a newborn platypus with alive=true, mutant=false, and age=0. Gender will randomly be 'm' or 'f' with equal probability. Weight will randomly be between 0.1 and 1.0 pounds. Name will default to “plipo”.

Think very carefully about writing the above functions and how they should be used. There are indeed circumstances when some functions should not execute. For example, a dead platypus shouldn't eat anything.

Your program should fully test your platypus class. It must call every member function in the platypus class. It must print to the screen what it is doing and show the changes that appear when the member functions are called. The fight function will require two platypuses: one to call the fight function and one to be a parameter in the fight function.

c++ language

In: Computer Science

What will the value of A represent at the end of execution of the given procedure...

What will the value of A represent at the end of execution of the given procedure on the “Paragraph Words” dataset?

Step 1. Arrange all cards in a single pile called Pile 1

Step 2. Maintain two variables A, B and initialize them to 0
Step 3. If Pile 1 is empty then stop the iteration

Step 4. Read the top card in Pile 1

Step 5. Add Letter count to variable B

Step 6. If the word does not end with a full stop then execute step 9

Step 7. If the word ends with a full stop and B > A then store B in A

Step 8. Reset the variable B to 0

Step 9. Move the current card to another pile called Pile 2 and repeat from step 3

Select answer from the following options:

1. Length of the shortest sentence based on the number of words

2. Length of the longest sentence based on the number of words

3. Length of the longest sentence based on the number of characters

4. Length of the shortest sentence based on the number of characters

5. None of the above

In: Computer Science

Describe the ramifications of the virtualization of storage.

Describe the ramifications of the virtualization of storage.

In: Computer Science

1. Why do we locked down bios? 2. What are the risk associated woth social engineers...

1. Why do we locked down bios?
2. What are the risk associated woth social engineers and physical access to computers
3. What is TPM and how does it help us?
4. What measurement can be taken against social engineer stealing a laptop

Minimum 6 rows please for each question. Thanks

In: Computer Science

1- Paper evaluation scenario a) Draw an ERD for the following relational schema: STUDENT (STD_ID, STD_First_Name,...

1- Paper evaluation scenario
a) Draw an ERD for the following relational schema:
STUDENT (STD_ID, STD_First_Name, STD_Last_Name, STD_Admit_Semester,
STD_Admit_Year, STD_Enroll_Status)
PAPER (PP_ID, PP_Title, PP_Submit_Date, PP_Accepted, PP_Type)
The two entities are related with the following business rule:
• Each student may write many papers
Explain your choice of minimum and maximum cardinalities.

b) Extend the existing ERD with an EVALUATOR entity. The job of the evaluator is to
grade each paper. The following business rules apply:
• Each paper is evaluated by at least 3 evaluators
Add four attributes of your choice to the EVALUATOR entity and extend the ERD. The
final solution must be an implementation ready ERD, which means you may need to add
additional entities or attributes to your ERD. In case you add additional entities, please
justify your choice of entities, primary keys, relationship types, and cardinalities.

I need this answer in Visual Paradigm please and also a very good reasoning for the cardinalities and extra entities

In: Computer Science

Write a function that takes a string as an argument checks whether it is a palindrome....

Write a function that takes a string as an argument checks whether it is a palindrome. A palindrome is a word that is the same spelt forwards or backwards. Use similar naming style e.g. name_pal. E.g. If we call the function as abc_pal(‘jason’) we should get FALSE and if we call it a abc_pal(‘pop’) we should get TRUE.

Hint: define your function as abc_pal(str). This indicates that string will be passed. Next create two empty lists L1=[] and L2=[] . Also create counter and set it to zero (e.g. i = 0). Now use a while loop e.g. while i < len(str) and use the append method to fill both empty lists i.e. List1.append(str[i]] and for list2 you need to reverse the order of filling i.e. L2 will be filled from the last letter to the first letter of the argument string. Lastly check if L1 is equal to L2 if the string is an anagram, simply use return L1==L2 this will return TRUE or FALSE as the case may be.

NB: Please use spider in anaconda(python) and include a picture of the code

In: Computer Science

HOW CAN I USE a string instead of array tries and res on this assignment, with...

HOW CAN I USE a string instead of array tries and res on this assignment, with out impacting the program or modifying too much on conditions  check code bellow

import java.util.Scanner;
import java.util.Random;//starter code provided
public class inputLap
{
public static char roller;
public static String playerName;
public static int printed=0;
public static int rounds=8,lives=0,randy;
public static int tries[]=new int[4];//use arrays to store number of tries in each life
public static int res[]=new int[4];
public static String getName(String aString){
Scanner sc= new Scanner(System.in);
System.out.println("enter player's Name:");aString=sc.next();
playerName=aString;
return playerName;
}

public static void menu()
{
Scanner sc= new Scanner(System.in);

if(lives<=4){
System.out.println("Do you want to continue?(y/Y):\n (x/X) to exit. ");roller=sc.next().charAt(0);
}
}

public static int getGame() {
Scanner sc = new Scanner(System.in);
System.out.println("make a guess from 1-20");
int Guessed = sc.nextInt();
return Guessed;
}

public static void main(String[] args) {
String name=getName(playerName);
Random r = new Random();
int answer=0;
int f=0;
while(true) {
randy=r.nextInt(20);
for (int i=0;i<=7;i++)
{
answer=getGame();
rounds--;
if(answer==randy)
{
lives++;
System.out.println("congratulation you are right");
tries[lives-1]=8-rounds;
res[lives-1]=1;
rounds=8;
break;
}
else
{
System.out.println("you have "+(rounds)+" remaining");

}
if(rounds==0){
if(lives!=4){
tries[lives]=8;
lives++;
  
System.out.println("hard luck\nyou have "+(4-lives)+" lives left");
f=1;
}
  
}
if(f==1){
f=0;
break;
}

}

menu();

switch( roller)

{

case 'y':

case 'Y':rounds=8;break;

case'x':

case 'X':

lives=5;
System.out.println("Game No Game 1 Game 2 Game 3 Game 4");
System.out.print("Number of tries ");
printed=1;
for(int i=0;i<4;i++)
System.out.print(tries[i]+" ");
System.out.println();
System.out.print("Result \t");
for(int i=0;i<4;i++){
if(res[i]==1)
System.out.print("Success ");
else
System.out.print("Fail");
}
System.out.println("\nbye bye "+playerName+" !!");

break;

}

if(lives>4)
break;
}

if(printed!=1){
System.out.println("Game No Game 1 Game 2 Game 3 Game 4");
System.out.print("Number of tries ");
for(int i=0;i<4;i++)
System.out.print(tries[i]+" ");
System.out.println();
System.out.print("Result\t");
for(int i=0;i<4;i++){
if(res[i]==1)
System.out.print("Success ");
else
System.out.print("Fail");
}
System.out.println("\nbye bye "+playerName+" !!");

}

}

}

In: Computer Science

NEED at least 1000 Words on this Please Discuss how physical security plays a huge role...

NEED at least 1000 Words on this Please

Discuss how physical security plays a huge role in the security information security infrastructure. Include discussions on Risk Assessment and Business Continuity Planning.

In: Computer Science

If you run the binary search method on a set of unordered data, What happens? Why?...

If you run the binary search method on a set of unordered data, What happens? Why? How you would correct this issue?

In: Computer Science

3. For this week’s assignment, you are asked to modify the above Java program to include...

3. For this week’s assignment, you are asked to modify the above Java program to include the following: - When the user clicks on the help menu, a drop-down list will appear with an item called About, then when the user clicks on it, the window will show some instructions about the functionality of the menu, e.g, what the edit menu does, etc. - When the user clicks on the File menu, a drop-down list will appear with one item called Show Picture, and when the user clicks on it, a picture of your choice will appear

import javax.swing.*;


public class MenuFrame extends JFrame {


public MenuFrame() {


setTitle("Menu Frame");

setSize(500, 500);

MenuListenerExample myMenu = new MenuListenerExample();


setJMenuBar(myMenu);

setLayout(null);

add(myMenu.textArea);


}


public static void main(String[] args) {

MenuFrame frame = new MenuFrame();

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

frame.setVisible(true);

}


}


import javax.swing.*;

import java.awt.event.*;



public class MenuListenerExample extends JMenuBar {


JMenu fileMenu, editMenu, helpMenu;

JMenuItem cut, copy, paste, selectAll,about,showPicture;

JTextArea textArea,textArea1;


public MenuListenerExample() {


cut = new JMenuItem("cut");

copy = new JMenuItem("copy");

paste = new JMenuItem("paste");

selectAll = new JMenuItem("selectAll");

about=new JMenuItem("about");

showPicture=new JMenuItem("show");

textArea = new JTextArea();

textArea1 = new JTextArea();


cut.addActionListener(new MenuAction());

copy.addActionListener(new MenuAction());

paste.addActionListener(new MenuAction());

selectAll.addActionListener(new MenuAction());

about.addActionListener(new MenuAction());

showPicture.addActionListener(new MenuAction());


fileMenu = new JMenu("File");

editMenu = new JMenu("Edit");

helpMenu = new JMenu("Help");


editMenu.add(cut);

editMenu.add(copy);

editMenu.add(paste);

editMenu.add(selectAll);

helpMenu.add(about);

fileMenu.add(showPicture);

add(fileMenu);

add(editMenu);

add(helpMenu);


textArea.setBounds(30, 30, 430, 400);

textArea1.setBounds(30, 30, 430, 400);


}


private class MenuAction implements ActionListener {


public void actionPerformed(ActionEvent e) {

if (e.getSource() == cut) {

textArea.cut();

}

if (e.getSource() == paste) {

textArea.paste();

}

if (e.getSource() == copy) {

textArea.copy();

}

if (e.getSource() == selectAll) {

textArea.selectAll();

}

if (e.getSource() == about) {

JFrame frame = new JFrame("about");

textArea1.setText("This is simple Notepad Application\n"+"1.File : It has show picture option\n"

+"Edit : It has three option cut,copy,selectall\n"+

"help : It has about option which show function\n");

textArea1.setEditable(false);

frame.add(textArea1);

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

frame.setVisible(true);

}


Replace if statements and use the switch statement


i need output show pictures in file menu

Image path is

C:\\Users\\DGL2\\Desktop\\3840.jpg_wh860.jpg

In: Computer Science