Questions
1) How do you read the contents of a text file that contains whitespace characters as...

1) How do you read the contents of a text file that contains whitespace

characters

as part of its data?

2) What capability does the fstream data type provide that the ifstream

and ofstream

data types do not?

3) What header file do you need to include in a program that performs

file operations?

4) What data type do you use when you want to create a file stream object

that

can write data to a file?

5) What data type do you use when you want to create a file stream object

that

can read data from a file?

6) Why should a program close a file when it

s finished using it?

7) Write code that does the following:

(a) Opens an output file with the filename Numbers.txt ,

uses a loop to write the numbers 1 through 100 to the file,

and then closes the file.

(b) Opens the Numbers.txt file that was created in Part 7a,

reads all of the numbers from the file and

displays them in rows of 10 values, and then closes the file.

(c) Add all of the numbers read from the file and displays their

total.

In: Computer Science

The use of computers in education is referred to as computer-assisted instruction (CAI). More sophisticated CAI...

The use of computers in education is referred to as computer-assisted instruction (CAI). More sophisticated CAI systems monitor the student’s performance over a period of time. The decision to begin a new topic is often based on the student’s success with previous topics. Modify the following auxiliary program (Computers are playing an increasing role in education. Write a program that will help an elementary school student learn multiplication. Use rand to produce two positive one-digit integers. It should then type a question such as: How much is 8 * 9? The student then types the answer. Your program checks the student’s answer. If it is correct, print “Very good!” and then ask another addition question. If the answer is wrong, print “No. Please try again.” and then let the student try the same question again repeatedly until the student finally gets it right. Terminate the program when the student has 5 right answers.) to count the number of correct and incorrect responses typed by the student. After the student types 5 answers, your program should calculate the percentage of correct responses. If the percentage is lower than 75 percent, your program should print “Please ask for extra help” and then terminate. If the percentage is 75 percent or higher, your program should print “Good work!” and then terminate.

I am programming student so please keep code simple enough that I can learn from it thanks

In: Computer Science

Create a program that will loop and prompt to enter the highlighted data items in the...

Create a program that will loop and prompt to enter the highlighted data items in the structure below. This is every item except customerNumber , isDeleted and newLine;


const int NAME_SIZE = 20;
const int STREET_SIZE = 30;
const int CITY_SIZE = 20;
const int STATE_CODE_SIZE = 3;

struct Customers {
    long customerNumber;
    char name[NAME_SIZE];
    char streetAddress_1[STREET_SIZE];
    char streetAddress_2[STREET_SIZE];
    char city[CITY_SIZE];
    char state[STATE_CODE_SIZE];
    int zipCode;

    char isDeleted;
    char newLine;
};

Always set the item isDeleted to 'N' and newline to '\n'. The item newLine is a convenient item that is there to assist in viewing the contents of the file using "type filename" the cmd window.

Notepad will show the binary chars and will not line up the data as expected. You may see some odd characters after the expected data for the character arrays. That is normal for C/C++.

The item customerNumber should start at 0 and increase by 1 for every record written.


Once the data in the structure is loaded, write it to the file "Customers.dat" and prompt to continue. If the reply is to not continue, close the file and exit.

The file "Customers.dat" must be opened in Binary mode.

1. Modify this program to open the file "Customers.dat" so that all data is written to the end of the file AND to allow the file to be read.

2. Create a method called "getLargestCustomerNumber" and call it after the "Customers.dat" file has been opened. Read all the existing customerNumbers and determine the largest customerNumber - do not assume the last record in the file is the largest number. Use this number as the base when adding new customer data.

3. Display the customer number calculated for the customer number that is receiving input.

4. The program needs to create the Customers.dat file if it does not exist.

5. The program should be able to start multiple times and add data with increasing customerNumbers. There should be no duplicated customer numbers.

In: Computer Science

1. public class MyString { private char[] data; MyString(String string) { data = string.toCharArray(); } public...

1.
public class MyString {
    private char[] data;

    MyString(String string) { data = string.toCharArray(); }
    public int compareTo(MyString other) { /* code from HW1 here */ }
    public char charAt(int i) { return data[i]; }
    public int length() { return data.length; }
    public int indexOf(char c) { /* code from HW1 here */ }
    public boolean equals(MyString other) { /* code from HW1 here */ }

    /*
    * Change this MyString by removing all occurrences of
    * the argument character c. For example, if MyString s
    * represents the text "radar", then s.remove('a') will
    * change s so that it now represents the text "rdr".
    */
    public void remove(char c) {
        /* Type in the box below the code that should go here. */
    }
}

public class ArrayIntSet {

private int[] data;

private int size;

public ArrayIntSet(int capacity) {

data = new int[capacity];

size = 0;

}

2.

public int size() { return size; }

public boolean contains(int i) { /* Code from HW3 here */ }

public boolean addElement(int element) { /* Code from HW3 here */ }

private int index(int element) { /* Code from HW3 here */ }

public boolean removeElement(int element) { /* Code from HW3 here */ }

public boolean equals(ArrayIntSet other) { /* Code from HW3 here */ }

public void union(ArrayIntSet other) { /* Code from HW3 here */ }

public void intersect(ArrayIntSet other) { /* Code from HW3 here */ }

/*

* Returns a new ArrayIntSet that contains

* all the even numbers from this set.

*/

public ArrayIntSet evenSubset() {

/* Write code for this method in the box below */

}

}

In: Computer Science

I don't know why my java code is not running this error code pops up -->...

I don't know why my java code is not running this error code pops up --> Error: Could not find or load main class DieRoll Caused by: java.lang.ClassNotFoundException: DieRoll.

Code below:

   import java.util.Random;

   import java.util.Scanner;

   public class Assignment {

   public static void combineStrings() {

   String school = "Harvard";

   String city = "Boston, MA";

   int stringLen;

  

   String upper, changeChar, combine;

  

   stringLen = school.length();

   System.out.println(school+" contains "+stringLen+" characters." );

  

   upper = school.toUpperCase();

   System.out.println(upper);

  

   changeChar = upper.replace("A", "*");

   combine = school +" "+city;

   System.out.println("The final string is "+combine );

   }

  

   public static void dieRoll()

   {

   Scanner scanner = new Scanner(System.in);

   Random random = new Random();

   int sides, n1, n2, n3;

  

   System.out.print("How many sides? ");

   sides = scanner.nextInt();

  

  

   n1 = random.nextInt(sides)+1;

   n2 = random.nextInt(sides)+1;

   n3 = random.nextInt(sides)+1;

  

   System.out.println("First Roll\t="+n1);

   System.out.println("Second Roll\t="+n2);

   System.out.println("Third Roll\t="+n3);

   System.out.println("Die Total\t="+(n1+n2+n3));

   System.out.println("Average Roll\t="+((n1+n2+n3)/3.0));

   }

  

  

   public static void candy()

   {

   int numCarton=0,candyBars;

   Scanner scanner = new Scanner(System.in);

  

   System.out.println("Enter the number of candy bars : ");

   candyBars = scanner.nextInt();

   do

   {

   numCarton++;

   candyBars = candyBars-24;

   }while(candyBars > 0);

  

   System.out.println("Number of Cartons needed = "+numCarton);

   }

  

public static void main(String[] args) {

  

   combineStrings();

   dieRoll();

   candy();

   }

}

In: Computer Science

Design the Class Diagram (UML) for a banking system with its clients’ accounts and an ATM...

Design the Class Diagram (UML) for a banking system with its clients’ accounts and an ATM machine. Each client account holds the user’s name (String of Full Name), account number (int) and balance (int). All client account details should be hidden from other classes but the system should provide tools/methods to access, change, and display (toString for account) each of these details.

The ATM machine holds the available money inside it (double) and the maximum money it can hold (double).

A user can request to withdraw, deposit or display balance through their account after checking the possibility of the action based on the ATM machine attributes. The balance display can be directly sent to the ATM. However, the withdraw request needs checking the user’s balance before checking the cash availability in the ATM machine. Also the deposit requires ensuring that the amount of cash will not exceed the maximum of the ATM.

For example, if the machine is full with cash then a user cannot deposit his money and a message should be displayed to the client that the machine is full and money cannot be deposited. In addition, if the machine has lower amount than what the withdraw request requires, the operation will be cancelled with an appropriate message on the standard output.

Use a default constructor (no formal parameters) and a full constructor (all class variables are initialized from formal parameters) for the client account.

object oriented programming "" Eclipse java"

In: Computer Science

Describe and give an example of the following: CyberTerrorism, Hacktivism, Black Hat Hacking, CyberCrime, CyberEspionage, CyberWar.

Describe and give an example of the following: CyberTerrorism, Hacktivism, Black Hat Hacking, CyberCrime, CyberEspionage, CyberWar.

In: Computer Science

Create a function output() in C that takes the pointer to the array and its size...

Create a function output() in C that takes the pointer to the array and its size and prints the arrays' contests.

(function prototype : void output(int *arrayPtr, int size);

In: Computer Science

in java Create the classes SubstitutionCipher and ShuffleCipher, as described below: 1. SubstitutionCipher implements the interfaces...

in java

Create the classes SubstitutionCipher and ShuffleCipher, as described below: 1. SubstitutionCipher implements the interfaces MessageEncoder and MessageDecoder. The constructor should have one parameter called shift. Define the method encode so that each letter is shifted by the value in shift. For example, if shift is 3, a will be replaced by d, b will be replaced by e, c will be replaced by f, and so on. (Hint: You may wish to define a private method that shifts a single character.)

In: Computer Science

Kitchen Gadgets sells a line of high-quality kitchen utensils and gadgets. When customers place orders on...

Kitchen Gadgets sells a line of high-quality kitchen utensils and gadgets. When customers place orders on the company’s Web site or through electronic data interchange (EDI), the system checks to see if the items are in stock, issues a status message to the customer, if they are in stock the customer will pay, the system will generate a shipping order to the warehouse, which fills the order. When the order is shipped, the customer is billed. The system also produces inventory reports to the accounting department. Complete the following tasks:

  1. Draw a context diagram for the order system.

  1. Draw a diagram 0 DFD for the order system.

In: Computer Science

Q5. [10] The left quotient of a regular language L1 with respect to L2 is defined...

Q5. [10] The left quotient of a regular language L1 with respect to L2 is defined as:
               L2/L1 = { y | x L2 , xy L1 }
Show that the family of regular languages is closed under the left quotient with a regular language.
Hint: Do NOT construct a DFA that accepts L2/L1 but use the definition of L2/L1 and the closure
properties of regular language.

In: Computer Science

Write a program that reads n integer values. If a negative value is entered, we want...

Write a program that reads n integer values. If a negative value is entered, we want to terminate the input, i.e., exit from the loop. If a zero value is entered, we want to ignore it and read the next value. Any strictly positive values (greater or equal zero) are to be totaled. Print the number of values read, the number of values totaled and the total. If a negative value is entered, print an error message before terminating the loop.

write in c plus plus

In: Computer Science

Create a Square Class and Create a graphical representation of your Square class - your class...

Create a Square Class and Create a graphical representation of your Square class

- your class will have the following data fields: double width, String color.

- provide a no-args constructor.

- provide a constructor that creates a square with the specific width

- implement method getArea()

- implement method getPerimeter()

- implement method setColor().

- draw a UML diagram for your class

- write a test program that will create a square with the width 30, 40 and 50.

Display the width, area and perimeter of each of your squares.

In: Computer Science

Use Google to search for online storage services or cloud backup. Look for an article or...

Use Google to search for online storage services or cloud backup. Look for an article or post that describes available services for remote backups. List two services and locate additional information about each, including how to enroll, costs to use, known security risks or breaches and customer reviews. Find articles that describe how companies are adopting online storage services and locate statistics about how many currently are doing so as well as predictions. Have you ever used an online storage service for backup or data recovery? If so, describe the experience. Submit your findings in a brief 250 word essay. Identify at least one URL used as a research source.

In: Computer Science

C++ Programming. Create a class hierarchy to be used in a university setting. The classes are...

C++ Programming.

Create a class hierarchy to be used in a university setting. The classes are as follows:

The base class isPerson. The class should have 3 data members: personID (integer), firstName(string), and lastName(string). The classshould also have a static data member called nextID which is used to assignanID numbertoeach object created(personID). All data members must be private.

Create the following member functions: Accessor functions to allow access to first name and last name (updates and retrieval). These functions should be public. Create a getID function to retrieve the personID of the person. This function should be public. The user oftheclassor any derived class should not have the ability to update personID. Create a constructor with two arguments(first name and last name) with default values.

Create a public member function Print to display information stored in the object. Make this class an abstract class. Create theStudent class as a derived class from the Person class. This class should have two additional data members to keep track of astudent’s GPA (float) and admission term (string –eg. Fall 2019). Create public accessor functions to allow access to the GPA and admission term. The setGPA function should return true if the value of the GPA is between 0 and 4.0(inclusive) and false otherwise. Set the GPA to zero if an invalid value is provided. Override the function Print to print the student information. Create a constructor that takes in four argumentswith default values(first name, last name, admission term, and GPA). Create the Faculty class as a derived class from the Person class. This class should have one additional data member to keep track of the yearthe faculty was hired(string –eg. 2019 ) Create a public accessor functionto allowaccess to the hire year. Override the function Print to print the faculty information. Create a constructor that takes in three argumentswith default values(first name, last name, hire year).

After defining the classes in this hierarchy, write a program that creates objects of each class and tests their member functions. Make sure you include the preprocessor directives (#ifndef, #define, #endif) to prevent a header file from being included (#include) multiple times. Separate the class interface from the class implementation.

Output Sample:

Faculty First Name: John

Faculty Last Name:Smith

Faculty ID:5

Faculty Hire Year:2019

******************************************************

******************************************************

Student First Name: Sarah

Student Last Name: Smith

Student ID: 3

Student GPA: 3.75

Student Admit Term: Fall 2019

In: Computer Science