Questions
Describe, step-by-step, what the Little Man does to execute an UNCODITIONAL BRANCH instruction. If a user...

  1. Describe, step-by-step, what the Little Man does to execute an UNCODITIONAL BRANCH instruction.
  1. If a user wants to enter two numbers, what must the Little Man program do before she enters the second number?  Why?

  1. Write a Little Man program that accepts two numbers as input and outputs the numbers in reverse order.
  1. Even if he runs out of instructions to execute, the Little Man only stops trying to execute instructions under one condition.  What is that condition?  What happens if the Little Man runs out of instructions and that condition is not met?
  1. When a value is copied from one register to another, what happens to the value in the sourceregister?  What happens to the value in the destinationregister?
  1. If the memory register for a particular computer is 32 bits wide, how much memory can this computer support?

In: Computer Science

Can you do this please: the code should be java just give me this and I...

Can you do this please: the code should be java

just give me this and I will finish the rest don't worry about infix or postfix conversion and evaluation.

just I need these two string should give value. and get a new string like this "12+34-/5".

String s = "ab+cd-/e*"

String s1 = "1232451"

I need code giving each character of String s value of strings1 ignoring operators.

example: a = 1, b = 2, c = 32, d = 4, e = 51, then give me new String like "12+324-/51*"

thank you

In: Computer Science

Cloud computing has a litany of necessary requirements. The business case needs to showcase the necessity...

Cloud computing has a litany of necessary requirements. The business case needs to showcase the necessity for moving to the cloud as well as an understanding of the cost benefit analysis. You should showcase a positive outcome for such a move outlining the overall inception and systems lifecycle process. As such, discuss the following questions in order to define what sufficient means and how to interpret a cost benefit analysis:

  • What is required for the business need to be identified and who makes the decision to move forward with a course of action?
  • What is a cost/benefit analysis and how does that factor into the decision to migrate into the cloud?
  • What sort of risks exist and how might those be mitigated?

In: Computer Science

# please answer question asap please Write a program in C to insert new value in...

# please answer question asap please

Write a program in C to insert new value in the array (unsorted list).

Use pointer notation for the array elements

.Test Data:Input the size of array: 4 Input 4 elements in the array in ascending order:

element -0: 2

element -1: 9

element -2: 7

element -3: 12

Input the value to be inserted: 5

Input the Position, where the value to be inserted: 2

Expected Output:The current list of the array:2 9 7 12

After Insert the element the new list is:2 5 9 7 12

In: Computer Science

MINIMUM MAIN.CPP CODE /******************************** * Week 4 lesson:               * *   finding the smallest number * *********************************/...

MINIMUM MAIN.CPP CODE

/********************************
* Week 4 lesson:               *
*   finding the smallest number *
*********************************/

#include <iostream>

using namespace std;

/*
* Returns the smallest element in the range [0, n-1] of array a
*/
int minimum(int a[], int n)
{
   int min = a[0];

   for (int i = 1; i < n; i++)
       if (min > a[i]) min = a[i];

   return min;
}

int main()
{
   int a[10];

   for (int i = 0; i < 10; i++)
   {
       a[i] = rand()%100;
       cout << a[i] << " ";
   }

   cout << endl << "Min = " << minimum(a, 10) << endl;

   return 0;

}

FACTORIAL MAIN.CPP CODE

/************************************************
*   implementing a recursive factorial function *
*************************************************/

#include <iostream>

using namespace std;

/*
* Returns the factorial of n
*/
long factorial(int n)
{
   if (n == 1)
       return 1;
   else
       return n * factorial(n - 1);
}

int main()
{
   int n;

   cout << "Enter a number: ";
   cin >> n;

   if (n > 0)
       cout << n << "!= " << factorial(n) << endl;
   else
       cout << "Input Error!" << endl;   return 0;
}

SORTING ALGORITHMS ARRAYLIST CODE

/********************************************
* Week 4 lesson:                           *
*   ArrayList class with sorting algorithms *
*********************************************/

#include <iostream>
#include "ArrayList.h"

using namespace std;

/*
* Default constructor. Sets length to 0, initializing the list as an empty
* list. Default size of array is 20.
*/
ArrayList::ArrayList()
{
   SIZE = 20;
   list = new int[SIZE];
   length = 0;
}

/*
* Destructor. Deallocates the dynamic array list.
*/
ArrayList::~ArrayList()
{
   delete [] list;
   list = NULL;
}

/*
* Determines whether the list is empty.
*
* Returns true if the list is empty, false otherwise.
*/
bool ArrayList::isEmpty()
{
   return length == 0;
}

/*
* Prints the list elements.
*/
void ArrayList::display()
{
   for (int i=0; i < length; i++)
       cout << list[i] << " ";
   cout << endl;
}

/*
* Adds the element x to the end of the list. List length is increased by 1.
*
* x: element to be added to the list
*/
void ArrayList::add(int x)
{
   if (length == SIZE)
   {
       cout << "Insertion Error: list is full" << endl;
   }
   else
   {
       list[length] = x;
       length++;
   }
}

/*
* Removes the element at the given location from the list. List length is
* decreased by 1.
*
* pos: location of the item to be removed
*/
void ArrayList::removeAt(int pos)
{
   if (pos < 0 || pos >= length)
   {
       cout << "Removal Error: invalid position" << endl;
   }
   else
   {
       for ( int i = pos; i < length - 1; i++ )
           list[i] = list[i+1];
       length--;
   }
}

/*
* Bubble-sorts this ArrayList
*/
void ArrayList::bubbleSort()
{
   for (int i = 0; i < length - 1; i++)
       for (int j = 0; j < length - i - 1; j++)
           if (list[j] > list[j + 1])
           {
               //swap list[j] and list[j+1]
               int temp = list[j];
               list[j] = list[j + 1];
               list[j + 1] = temp;
           }
}

/*
* Quick-sorts this ArrayList.
*/
void ArrayList::quicksort()
{
   quicksort(0, length - 1);
}

/*
* Recursive quicksort algorithm.
*
* begin: initial index of sublist to be quick-sorted.
* end: last index of sublist to be quick-sorted.
*/
void ArrayList::quicksort(int begin, int end)
{
   int temp;
   int pivot = findPivotLocation(begin, end);

   // swap list[pivot] and list[end]
   temp = list[pivot];
   list[pivot] = list[end];
   list[end] = temp;

   pivot = end;

   int i = begin,
       j = end - 1;

   bool iterationCompleted = false;
   while (!iterationCompleted)
   {
       while (list[i] < list[pivot])
           i++;
       while ((j >= 0) && (list[pivot] < list[j]))
           j--;

       if (i < j)
       {
           //swap list[i] and list[j]
           temp = list[i];
           list[i] = list[j];
           list[j] = temp;

           i++;
           j--;
       } else
           iterationCompleted = true;
   }

   //swap list[i] and list[pivot]
   temp = list[i];
   list[i] = list[pivot];
   list[pivot] = temp;

   if (begin < i - 1)
       quicksort(begin, i - 1);
   if (i + 1 < end)
       quicksort(i + 1, end);
}

/*
* Computes the pivot location.
*/
int ArrayList::findPivotLocation(int b, int e)
{
   return (b + e) / 2;
}

SORTING ALGORITHMS ARRAYLIST HEADER

/********************************************
* Week 4 lesson:                           *
*   ArrayList class with sorting algorithms *
*********************************************/

/*
* Class implementing an array based list. Bubblesort and quicksort algorithms
* are implemented also.
*/
class ArrayList
{
public:
   ArrayList ();
   ~ArrayList();
   bool isEmpty();
   void display();
   void add(int);
   void removeAt(int);
   void bubbleSort();
   void quicksort();
private:
   void quicksort(int, int);
   int findPivotLocation(int, int);
   int SIZE;       //size of the array that stores the list items
   int *list;       //array to store the list items
   int length;   //amount of elements in the list
};

SORTING ALGORITHMS MAIN.CPP CODE

/********************************************
* Week 4 lesson:                           *
*   ArrayList class with sorting algorithms *
*********************************************/

#include <iostream>
#include "ArrayList.h"
#include <time.h>

using namespace std;

/*
* Program to test the ArrayList class.
*/
int main()
{
   srand((unsigned)time(0));

   //creating a list of integers
   ArrayList numbersCopy1, numbersCopy2;


    //filling the list with random integers
    for (int i = 0; i<10; i++)
   {
       int number = rand()%100;
       numbersCopy1.add(number);
       numbersCopy2.add(number);
   }

    //printing the list
    cout << "Original list of numbers:" << endl <<"\t";
    numbersCopy1.display();

    //testing bubblesort
    cout << endl << "Bubble-sorted list of numbers:" << endl <<"\t";
    numbersCopy1.bubbleSort();
    numbersCopy1.display();

    //testing quicksort
    cout << endl << "Quick-sorted list of numbers:" << endl <<"\t";
   numbersCopy2.quicksort();
    numbersCopy2.display();

   return 0;
}

QUESTIONS

PART 1

Design and implement an algorithm that, when given a collection of integers in an unsorted array, determines the third smallest number (or third minimum). For example, if the array consists of the values 21, 3, 25, 1, 12, and 6 the algorithm should report the value 6, because it is the third smallest number in the array. Do not sort the array.

To implement your algorithm, write a function thirdSmallest that receives an array as a parameter and returns the third-smallest number. To test your function, write a program that populates an array with random numbers and then calls your function.

PART 2

The following problem is a variation of Exercise C-4.27 in the Exercises section of Chapter 4 in Data Structures and Algorithms in C++ (2nd edition) textbook.

Implement a recursive function for computing the n-th Harmonic number:

Hn=∑i=1n1i/

Here you have some examples of harmonic numbers.

H1 = 1
H2 = 1 + 1/2 = 1.5
H3 = 1 + 1/2 + 1/3 = 1.8333
H4 = 1 + 1/2 + 1/3 + 1/4 = 2.0833

PART 3

In this week's lesson, the algorithms quicksort and bubblesort are described. In Sorting Algorithms (Links to an external site.) you can find the class ArrayList, where these sorting algorithms are implemented. Write a program that times both of them for various list lengths, filling the array lists with random numbers. Use at least 10 different list lengths, and be sure to include both small values and large values for the list lengths (it might be convenient to add a parameterized constructor to the class ArrayList so the size of the list can be set at the moment an ArrayList object is declared).

Create a table to record the times as follows.

List Length Bubblesort Time
(seconds)
Quicksort Time
(seconds)

Regarding the efficiency of both sorting methods, what are your conclusions? In addition to the source code and a screenshot of the execution window, please submit a separate document with the table and your conclusions about the experiment.

Note: To time a section of your source code, you can do this.

#include <chrono>

using namespace std;

int main()
{
    start = chrono::steady_clock::now();
     //add code to time here
    end = chrono::steady_clock::now();
    chrono::duration<double> timeElapsed = chrono::duration_cast<chrono::duration<double>>(end-start);
    cout << "Code duration: "  << timeElapsed.count() << " seconds" << endl;      
}

In: Computer Science

C PROGRAMMIMG I want to check if my 2 input is a number or not all...

C PROGRAMMIMG

I want to check if my 2 input is a number or not

all of the input are first stored in an array if this the right way?

read = sscanf(file, %s%s%s, name, num, last_name);

if(strcmp(num, "0") != 0)

printf("Invalid. Please enter a number.")

In: Computer Science

CORAL LANGUAGE ONLY Write a function DrivingCost with parameters drivenMiles, milesPerGallon, and dollarsPerGallon, that returns the...

CORAL LANGUAGE ONLY

Write a function DrivingCost with parameters drivenMiles, milesPerGallon, and dollarsPerGallon, that returns the dollar cost to drive those miles. All items are of type float.

Ex: If the function is called with 50 20.0 3.1599, the function returns 7.89975.

Define that function in a program whose inputs are the car's miles/gallon and the gas dollars/gallon (both floats). Output the gas cost for 10 miles, 50 miles, and 400 miles, by calling your DrivingCost function three times.

Ex: If the input is 20.0 3.1599, the output is:

1.57995 7.89975 63.198

Note: Small expression differences can yield small floating-point output differences due to computer rounding. Ex: (a + b)/3.0 is the same as a/3.0 + b/3.0 but output may differ slightly. Because our system tests programs by comparing output, please obey the following when writing your expression for this problem. In the DrivingCost function, use the variables in the following order to calculate the cost: drivenMiles, milesPerGallon, dollarsPerGallon.

In: Computer Science

Project 7-6: Sales Tax Calculator Create a program that uses a separate module to calculate sales...

Project 7-6: Sales Tax Calculator

Create a program that uses a separate module to calculate sales tax and total after tax.

Create a c++ program using console.h and console.cpp files that uses a separate module to calculate sales tax and total after tax.

Console

Sales Tax Calculator

ENTER ITEMS (ENTER 0 TO END)

Cost of item: 35.99

Cost of item: 27.50

Cost of item: 19.59

Cost of item: 0

Total:           83.08

Sales tax:        4.98

Total after tax: 88.06

Again? (y/n): y

ENTER ITEMS (ENTER 0 TO END)

Cost of item: 152.50

Cost of item: 59.80

Cost of item: 0

Total:           212.30

Sales tax:        12.74

Total after tax: 225.04

Again? (y/n): n

Thanks, bye!

Specifications

  • The program should only accept numbers that are greater than 0.
  • Use the console.h and console.cpp files described in chapter 7 to validate user entries. That way, the user can’t crash the program by entering invalid data.
  • The sales tax rate should be 6% of the total.
  • Use a header file to declare two functions. One should accept the total of the items and return the tax amount. The other should accept the total of the items and return the total after tax has been added.
  • Use the implementation file for this header file to store the sales tax rate and the definitions for these two functions. These functions should round the results to two decimal places.
  • The output should display all monetary values with 2 decimal places.
  • The output should right align the numbers in the second column. This makes it easier to check whether the calculations are correct.

been added. • Use the implementation file for this header file to store the sales tax rate and the definitions for these two functions. These functions should round the results to two decimal places. • The output should display all monetary values with 2 decimal places. • The output should right align the numbers in the second column. This makes it easier to check whether the calculations are correct.

In: Computer Science

Answer correctly the below 25 multiple questions on Software Development Security. Please I will appreciate the...

Answer correctly the below 25 multiple questions on Software Development Security. Please I will appreciate the Correct Answer ONLY

1. Which of the following correctly best describes an object-oriented database?

  1. When an application queries for data, it receives both the data and the procedure.
  2. It is structured similarly to a mesh network for redundancy and fast data retrieval.
  3. Subjects must have knowledge of the well-defined access path in order to access data.
  4. The relationships between data entities provide the framework for organizing data.

2. Fred has been told he needs to test a component of the new content management application under development to validate its data structure, logic, and boundary conditions. What type of testing should he carry out?

  1. Acceptance testing
  2. Regression testing
  3. Integration testing
  4. Unit testing

3. Which of the following is the best description of a component-based system development method?

  1. Components periodically revisit previous stages to update and verify design requirements
  2. Minimizes the use of arbitrary transfer control statements between components
  3. Uses independent and standardized modules that are assembled into serviceable programs
  4. Implemented in module-based scenarios requiring rapid adaptations to changing client requirements

4. There are many types of viruses that hackers can use to damage systems. Which of the following is not a correct description of a polymorphic virus?

  1. Intercepts antimalware's call to the operating system for file and system information
  2. Varies the sequence of its instructions using noise, a mutation engine, or random-number generator
  3. Can use different encryption schemes requiring different decryption routines
  4. Produces multiple varied copies of itself

5. Which of the following best describes the role of the Java Virtual Machine in the execution of Java applets?

  1. Converts the source code into bytecode and blocks the sandbox
  2. Converts the bytecode into machine-level code
  3. Operates only on specific processors within specific operating systems
  4. Develops the applets, which run in a user's browser

6. What type of database software integrity service guarantees that tuples are uniquely identified by primary key values?

  1. Concurrent integrity
  2. Referential integrity
  3. Entity integrity
  4. Semantic integrity

7. In computer programming, cohesion and coupling are used to describe modules of code. Which of the following is a favorable combination of cohesion and coupling?

  1. Low cohesion, low coupling
  2. High cohesion, high coupling
  3. Low cohesion, high coupling
  4. High cohesion, low coupling

8. Which of the following statements does not correctly describe SOAP and Remote Procedure Calls?

  1. SOAP was designed to overcome the compatibility and security issues associated with Remote Procedure Calls.
  2. Both SOAP and Remote Procedure Calls were created to enable application-layer communication.
  3. SOAP enables the use of Remote Procedure Calls for information exchange between applications over the Internet.
  4. HTTP was not designed to work with Remote Procedure Calls, but SOAP was designed to work with HTTP.

9. Which of the following is a correct description of the pros and cons associated with third-generation programming languages?

  1. The use of heuristics reduced programming effort, but the amount of manual coding for a specific task is usually more than the preceding generation.
  2. The use of syntax similar to human language reduced development time, but the language is resource intensive.
  3. The use of binary was extremely time consuming but resulted in fewer errors.
  4. The use of symbols reduced programming time, but the language required knowledge of machine architecture.

10. It can be very challenging for programmers to know what types of security should be built into the software that they create. The amount of vulnerabilities, threats, and risks involved with software development can seem endless. Which of the following describes the best first step for developers to take to identify the security controls that should be coded into a software project?

  1. Penetration testing
  2. Regression testing
  3. Threat modeling
  4. Attack surface analysis

11. Mary is creating malicious code that will steal a user's cookies by modifying the original client-side Java script. What type of cross-site scripting vulnerability is she exploiting?

  1. Second order
  2. DOM-based
  3. Persistent
  4. Nonpersistent

12. Of the following steps that describe the development of a botnet, which best describes the step that comes first?

  1. Infected server sends attack commands to the botnet.
  2. Spammer pays a hacker for use of a botnet.
  3. Controller server instructs infected systems to send spam to mail servers.
  4. Malicious code is sent out that has bot software as its payload.

13. Which of the following antimalware detection methods is the most recent to the industry and monitors suspicious code as it executes within the operating system?

  1. Behavior blocking
  2. Fingerprint detection
  3. Signature-based detection
  4. Heuristic detection

14. Which of the following describes object-oriented programming deferred commitment?

  1. Autonomous objects, which cooperate through exchanges of messages
  2. The internal components of an object can be refined without changing other parts of the system
  3. Object-oriented analysis, design, and modeling maps to business needs and solutions
  4. Other programs using same objects

15. __________________ provides a machine-readable description of the specific operations provided by a specific web service. ________________ provides a method for web services to be registered by service providers and located by service consumers.

  1. Web Services Description Language; Universal Description, Discovery and Integration
  2. Universal Description, Discovery and Integration; Web Services Description Language
  3. Web Services Description Language; Simple Object Access Protocol
  4. Simple Object Access Protocol; Universal Description, Discovery and Integration

16. Sally has found out that software programmers in her company are making changes to software components and uploading them to the main software repository without following version control or documenting their changes. This is causing a lot of confusion and has caused several teams to use the older versions. Which of the following would be the best solution for this situation?

  1. Software change control management
  2. Software escrow
  3. Software configuration management
  4. Software configuration management escrow

17. The approach of employing an integrated product team (IPT) for software development is designed to achieve which of the following objectives?

  1. Developing and testing software with fewer security flaws
  2. Developing and testing software with fewer defective features
  3. Developing and testing software that will be most profitable
  4. Developing and testing software best suited to the deployment environment

18. Which are the best reasons why a code versioning system (CVS) is an important part of a development infrastructure?

  1. It can ensure that code modifications are made according to corporate policies.
  2. It will document who made which changes to ensure accountability.
  3. It will reduce the cost of the development infrastructure.
  4. It can provide control over unauthorized access to proprietary code.
  1. i, ii, iv
  2. iii
  3. iii, iv
  4. All of the above

19. What is generally the safest, most secure way to acquire software?

  1. From a reputable vendor of proprietary software, once tested in the deployment environment
  2. Downloading very popular open-source software that has been inspected for bugs by a large and active community
  3. Downloading either proprietary or open-source software, but fuzzing it in a lab environment prior to deployment
  4. Downloading open-source software and deploying it only after the code base has been verified by cryptographic checksum

20. Cross-site scripting (XSS) is an application security vulnerability usually found in web applications. What type of XSS vulnerability occurs when a victim is tricked into opening a URL programmed with a rogue script to steal sensitive information?

  1. Persistent XSS vulnerability
  2. Nonpersistent XSS vulnerability
  3. Second-order vulnerability
  4. DOM-based vulnerability

21. Widgets, Inc.'s software development processes are documented, and the organization is capable of producing its own standard of software processes. Which of the following Capability Maturity Model Integration levels best describes Widgets, Inc.?

  1. Initial
  2. Repeatable
  3. Defined
  4. Managed

In: Computer Science

For this assignment you will write a program with multiple functions that will generate and save...

For this assignment you will write a program with multiple functions that will generate and save between 100 and 10,000 (inclusive) "Shakespearian" insults. The program InsultsNetID.py is supplied as a starting point and it contains some tests that you must pass. The program loads words from three separate files: word1.txt, word2.txt and word3.txt. Each file contains 50 words or phrases. An insult is generated by choosing one word or phrase from each of the three lists of words at random, adding "Thou " to the beginning and "!" to the end. One such random insult would be:

    Thou artless bat-fowling barnacle!

With this many words, you could generate 50 * 50 * 50, or 125,000 possible unique insults - more than enough for anyone! Your program does not have to generate more than 10,000 unique insults and will not generate less than 100 of them for saving to a file. Your program will need to generate unique insults (no two the same) and they must be in alphabetical order before being saved in a text file. You should use Python's built in list searching and sorting functionality.

If your program is working properly it should generate an output like SampleOutput.txt. The actual insults will be different. And a file called "Insults.txt" containing all the insults will also have been created. The file will contain the user specified number of unique insults in alphabetical order. The user should be able to supply any number of insults between 100 and 10,000. Input of this number should be completely robust. If he enters something non-numeric or outside the legal range, he should be continuously re-prompted to enter a legal value.

In: Computer Science

Write around 200 words only related to what do you understand about server virtualization.

Write around 200 words only related to what do you understand about server virtualization.

In: Computer Science

Write the Java program: In this assignment, you will create a program implementing the functionalities of...

Write the Java program:

In this assignment, you will create a program implementing the functionalities of a standard queue in a class called Queue3503. You will test the functionalities of the Queue3503 class from the main() method of the Main class. In a queue, first inserted items are removed first and the last items are removed at the end (imagine a line to buy tickets at a ticket counter).

The Queue3503 class will contain:
a. An int[] data filed named elements to store the int values in the queue.
b. An int data field named size that stores the number of elements in the queue.
c. A no-arg constructor that creates a Queue object with default capacity 0.
d. A constructor that takes an int argument representing the capacity of the queue.
e. A method with signature enqueue(int v) that adds the int element v into the queue.
f. A method with signature dequeue() that removes and returns the first element of the
queue.
g. A method with signature empty() that returns true if the queue is empty.
h. A method with signature getSize() that returns the size of the queue (return type is hence
int)).

The queue class you develop should be tested using the following steps: (In other words, your program named Main will consist of the following)


a. Start your queue with an initial capacity of 8.


b. When the dequeue() method is called, an element from the queue at the beginning of the queue must be removed.

c. The main() method in your Main class should consist of statements to:
i. Create a queue object;
ii. Call enqueue() to insert twenty integers (taken from the user) into the queue.
iii. After the above task is completed, include a for-loop that will print out the contents of the queue.


d. After printing the queue filled with twenty integers, call dequeue() repeatedly to remove the beginning element of the queue.


e. Print the contents of the queue after removing every fifth number.


f. For your reference, the execution of the Main program is shown below. User inputs for populating the Queue is shown in the first line. Next, your program outputs are shown.

*Make sure the code can run in Repl.it*

Points to think about

*Make sure the code can run in Repl.it*

  • Which data structure will be the best fit to implement this Queue class - Array or ArrayList?

Sample Run

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

Initial content: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

After removing 5 elements: 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

After removing 5 elements: 11 12 13 14 15 16 17 18 19 20

After removing 5 elements: 16 17 18 19 20

In: Computer Science

what is JSON and why we use it, what the threats are and how we mitigate...

what is JSON and why we use it, what the threats are and how we mitigate against them, how PHP sanitises the data, how MySQL save the data and how data gets from the server onto the web page.

In: Computer Science

You have a set of four drives configured as RAID-5. Drive #3 has crashed, but you...

You have a set of four drives configured as RAID-5.

Drive #3 has crashed, but you have the data from Drives 1, 2, and 4 as shown here:

Drive #1: 01001111 01101000 01001110 01101111

Drive #2: 01011001 01110101 01110000 00100001

Drive #3: XXXXXXXX XXXXXXXX XXXXXXXX XXXXXXXX

Drive #4: 01001111 01111100 01000111 01101111

What is the missing data in ASCII? Explain how you retrieved the information.

In: Computer Science

In the Gui need a file in and out writter. That also takes from in file...

In the Gui need a file in and out writter. That also takes from in file and out file. Write errors to no file found or wrong file. Clear button and Process buttons need to work.

import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.Scanner;
import java.io.*;

import javax.swing.*;

@SuppressWarnings("serial")
public class JFileChooserDemo extends JFrame implements ActionListener
{
private JTextField txtInFile;
private JTextField txtOutFile;
private JButton btnInFile;
private JButton btnOutFile;
private JButton btnProcess;
private JButton btnClear;
public JFileChooserDemo()
{
   Container canvas = this.getContentPane();
   canvas.setLayout(new GridLayout (3,1));
     
   canvas.add(createInputFilePanel());
   canvas.add(createOutputFilePanel());
   canvas.add(createButtonPanel());
   this.setVisible(true);
   this.setSize(800, 200);
   this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public JPanel createInputFilePanel()
{
   JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT));
   panel.add(new JLabel("In File"));
   txtInFile = new JTextField(60);
   panel.add(txtInFile);
   btnInFile = new JButton("In File");
   panel.add(btnInFile);
   btnInFile.addActionListener(this);
   return panel;
}
  
public JPanel createOutputFilePanel()
{
JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT));  
panel.add(new JLabel("Out File"));
txtOutFile = new JTextField(58);
panel.add(txtOutFile);
btnOutFile = new JButton("Out File");
panel.add(btnOutFile);
btnOutFile.addActionListener(this);
return panel;   
}
public JPanel createButtonPanel()
{
   JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER));
   btnProcess =new JButton("Process");
   btnProcess.addActionListener(this);
   panel.add(btnProcess);
  
   btnClear =new JButton("Clear");
   btnClear.addActionListener(this);
   panel.add(btnClear);
   return panel;
}
public static void main(String[] args)
{
   new JFileChooserDemo();
   Scanner file = null;
   PrintWriter fout= null;
           try {
               file = new Scanner(new File("numbers.txt"));
               fout = new PrintWriter("TotalSums.txt");
               while(file.hasNext())
               {
                  
                   @SuppressWarnings("resource")
                   Scanner line = new Scanner(file.nextLine());
   int totalSum = 0;
   while (line.hasNext()) {
   int number = line.nextInt();
   totalSum += number;
   fout.print(number);
   if (line.hasNext())
   {
   fout.print("+");
   }
   }
   fout.println("=" + totalSum);
   }
           }
           catch (FileNotFoundException e)
           {
              
               System.out.println("NOT FOUND");
           }
           finally
           {
               if(fout!=null)fout.close();
           }
          
           if(file!=null)file.close();
          
       }
      
      
  
  
public void clearInput()
{
txtInFile.setText(""); txtOutFile.setText("");

}
@Override
public void actionPerformed(ActionEvent e)
{
   if(e.getSource() == btnInFile)
   {
       JFileChooser jfcInFile = new JFileChooser();
       if(jfcInFile.showOpenDialog(this) != JFileChooser.CANCEL_OPTION)
       {
           File inFile = jfcInFile.getSelectedFile();
           txtInFile.setText(inFile.getAbsolutePath());
       }
       else
       {
          
       }
   }
   if(e.getSource() == btnProcess)
   {
       File file = new File(txtInFile.getText());
       try
       {
           Scanner fin = new Scanner(file);
       }
       catch (FileNotFoundException e1)
       {
          
           e1.printStackTrace();
       }
   }
  
}
}

In: Computer Science