(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 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.
In: Computer Science
By using javaFX, write and design the Towers of Hanoi game with Redo and Undo features with play and solve options.
In: Computer Science
In: Computer Science
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:
Your Animal_Category class is to contain the following member functions:
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:
Member functions:
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.
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 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.
In: Computer Science
In: Computer Science
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. 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 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 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? 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 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