Questions
Write a C++ program that creates a file called Readings.txt. Inside the file, your program must...

Write a C++ program that creates a file called Readings.txt. Inside the file, your program must create
a list. The list is composed of integer double pairs. There is one pair per line. The integers are in
sequence (0, 1, 2, 3, ...) beginning with zero and ending with some random value between 512 and
1024. The doubles should be random values between 50.000 and 90.000. The doubles only have 3
decimal places. The file should look like this (of course your doubles will be random, and there will
be more than 5 readings):


0, 56.347
1, 78.231
2, 89.999
3, 68.002
4, 55.128

In: Computer Science

PSEUDOCODE: 1. You are designing a 2 dimensional game where players shoot ​bullets​ hugs at each...

PSEUDOCODE:

1. You are designing a 2 dimensional game where players shoot ​bullets​ hugs at each other. Define a pseudocode function to determine whether a hug successfully 'hit' a player at a particular moment.

Real parameter playerX : target player's x position
Real parameter playerY : target player's y position
Real parameter bulletX : x position of bullet
Real parameter bulletY : y position of bullet
Return Boolean : True if distance between target and player within 10 False if not You may need to look up the formula for distance between points in 2d space. Do not use any library functions except 'pow' and 'sqrt' if you need them.

2.Define a pseudocode function that takes in an Integer and returns the absolute value of that integer. The solutions are notthe result of some programming trick but are more related to arithmetic and math and there are multiple solutions to this.

3.Define a function within a flow chart that has 2 Real parameters and returns the larger of them. If they are the same return either argument. DO NOT SUBMIT PSEUDOCODE FOR THIS.

4. The colors red, blue, and yellow are known as the primary colors because they cannot be made by mixing other colors. When you mix two primary colors, you get a secondary color, as shown here:

● When you mix red and blue, you get purple.
● When you mix red and yellow, you get orange. ● When you mix blue and yellow, you get green.

Design a program in pseudocode that prompts the user to enter the names of two primary colors to mix. If the user enters anything other than “red,” “blue,” or “yellow,” the program should display an error message. Otherwise, the program should display the name of the secondary color that results.

In: Computer Science

In a file called DivisibilityTests.java, write a program that: Asks the user to enter an integer....

In a file called DivisibilityTests.java, write a program that:

  • Asks the user to enter an integer. It is OK for your program to crash when the user does not enter a valid integer.
  • If the integer is less than 0, the program prints: "The number is negative."
  • If the integer is divisible by 2 and by 3, the program prints: "The number is even and divisible by 3."
  • If the integer is divisible by 2 but not by 3, the program prints "The number is even and not divisible by 3."
  • If the integer is divisible by 3 but not by 2, the program prints "The number is odd and divisible by 3."
  • If the integer is divisible by neither 2 nor 3, the program prints "The number is odd and not divisible by 3."

For example: if the user enters -5, your program output should look EXACTLY like this:

Please enter an integer: -5
The number is negative.

In: Computer Science

This assignment is 2 programs demonstrating IF statements and Decisions. Program 1 Write a program that...

This assignment is 2 programs demonstrating IF statements and Decisions.

Program 1

Write a program that asks a user for a temperature for two storage containers for a spaceship filled with water and oxygen. The program should tell if either is ice and if either is boiling.

Numbers to use for your tests

The Freezing point of water is 32 and the boiling point is 212.

The Freezing point of oxygen is -362 and the boiling point is -306.

Program 2

People eating at a restaurant get to eat for free if they are younger than 10, pay full price if they are under 65, get a $3 discount if they are 65 or over. Write a program asking the user for an age of the next customer and the price of the food they ordered. Calculate how much to charge based on the price (set to 0, full price, or with a discount) along with a 15% tip. Then have the program show this amount to the user.

Examples:

What age is the person

5

What price is the meal

10

The charge for this person is 0

(a second program run)

What age is the person

70

What price is the meal

10

The charge for this person is 8.05

In: Computer Science

Part 1 Here is some code: def foo(var): var = [] var.append("hello") var.append("world") list = ["bah"]...

Part 1

Here is some code:

def foo(var):
    var = []
    var.append("hello")
    var.append("world")

list = ["bah"]
foo(list)
print(list)

Which Option is correct?

A) ["hello","world"] is output because python passes the list by reference and the list is changed inside the function.

B) ["bah"] is output because python passes the list by value so changes to the list in the function are made to a separate list than the one that is passed in.

C) ["bah"] is output because python passes the list by reference but a new reference is created by the first line in the function so subsequent changes are made to a separate list than the one that is passed in.

Part 2

Consider this code:

list1 = []
list2 = list1

list2.append(1)
list2.append(2)
list1.append(3)

Which option is correct?

A) list1 contains [3] and list2 contains[1,2]

B) list1 contains [3] and list2 references the same list as list1

C) list1 contains [1,2,3] and list2 references the same list as list1

D) list2 contains [1,2,3] and list1 also contains [1,2,3] but the 3 is stored in a different location than list2


In: Computer Science

Project Description In this project you will build a car configuration application in six units. Each...

Project Description

In this project you will build a car configuration application in six units. Each unit provides learning opportunities in Object Oriented Design. You are expected to document these lessons and apply them in the next unit. You will notice that the design guidance will taper off as you progress through units in Project 1. You will be expected to design on your own.

Project 1 - Unit 1

In this project you will build a Car Configuration Application using Java. In this unit you will develop a “reference” base object model, read a text file to build the reference base object model and archive it using Serialization.

I would like you to start with a proof of concept – so we will first build the underlying object using normal Java Classes and Inner Classes.

For our proof of concept please consider the following requirements:

We will build Ford's Focus Wagon ZTW model with these options:

  • ● Color - Fort Knox Gold Clearcoat Metallic, Liquid Grey Clearcoat Metallic, Infra-Red Clearcoat, Grabber Green Clearcoat Metallic, Sangria Red Clearcoat Metallic, French Blue Clearcoat Metallic, Twilight Blue Clearcoat Metallic, CD Silver Clearcoat Metallic, Pitch Black Clearcoat, Cloud 9 White Clearcoat

  • ● Transmission - automatic or manual

  • ● Brakes/Traction Control - Standard, ABS, or ABS with Advance Trac

  • ● Side Impact Airbags - present or not present

  • ● Power Moonroof - present or not present
    Configuration options and cost data:

Base Price

$18,445

Color

No additional cost

Transmission

0 for automatic, $­815 for standard (this is a "negative option")

Brakes/Traction Control

$0 for standard, $400 for ABS, $1625 for ABS with Advance Trac

Side Impact Air Bags

$0 for none, $350 if selected

Power Moonroof

$0 for none, $595 if selected

Your Deliverable:

Design and code classes for these requirements and write a driver program to instantiate a Ford Wagon ZTW object and write it to a file. Test your code with a couple of instances of Forward Wagon ZTW.

Use the following driver (or something similar) for testing entire project.

class Driver {

public static void main(String [] args) {

//Build Automobile Object from a file.

Automobile FordZTW = (Some instance method in a class of Util package).readFile("FordZTW.txt");

//Print attributes before serialization

FordZTW.print();

//Serialize the object

Lab1.autoutil.FileIO.serializeAuto(FordZTW);

//Deserialize the object and read it into memory.

Automobile newFordZTW = Lab1.autoutil.FileIO.DeserializeAuto("auto.ser"); //Print new attributes.

newFordZTW.print();

}

}


In: Computer Science

Project Description In this project you will build a car configuration application in six units. Each...

Project Description

In this project you will build a car configuration application in six units. Each unit provides learning opportunities in Object Oriented Design. You are expected to document these lessons and apply them in the next unit. You will notice that the design guidance will taper off as you progress through units in Project 1. You will be expected to design on your own.

Project 1 - Unit 1

In this project you will build a Car Configuration Application using Java. In this unit you will develop a “reference” base object model, read a text file to build the reference base object model and archive it using Serialization.

I would like you to start with a proof of concept – so we will first build the underlying object using normal Java Classes and Inner Classes.

For our proof of concept please consider the following requirements:

We will build Ford's Focus Wagon ZTW model with these options:

  • ● Color - Fort Knox Gold Clearcoat Metallic, Liquid Grey Clearcoat Metallic, Infra-Red Clearcoat, Grabber Green Clearcoat Metallic, Sangria Red Clearcoat Metallic, French Blue Clearcoat Metallic, Twilight Blue Clearcoat Metallic, CD Silver Clearcoat Metallic, Pitch Black Clearcoat, Cloud 9 White Clearcoat

  • ● Transmission - automatic or manual

  • ● Brakes/Traction Control - Standard, ABS, or ABS with Advance Trac

  • ● Side Impact Airbags - present or not present

  • ● Power Moonroof - present or not present
    Configuration options and cost data:

Base Price

$18,445

Color

No additional cost

Transmission

0 for automatic, $­815 for standard (this is a "negative option")

Brakes/Traction Control

$0 for standard, $400 for ABS, $1625 for ABS with Advance Trac

Side Impact Air Bags

$0 for none, $350 if selected

Power Moonroof

$0 for none, $595 if selected

Your Deliverable:

Design and code classes for these requirements and write a driver program to instantiate a Ford Wagon ZTW object and write it to a file. Test your code with a couple of instances of Forward Wagon ZTW.

Use the following driver (or something similar) for testing entire project.

class Driver {

public static void main(String [] args) {

//Build Automobile Object from a file.

Automobile FordZTW = (Some instance method in a class of Util package).readFile("FordZTW.txt");

//Print attributes before serialization

FordZTW.print();

//Serialize the object

Lab1.autoutil.FileIO.serializeAuto(FordZTW);

//Deserialize the object and read it into memory.

Automobile newFordZTW = Lab1.autoutil.FileIO.DeserializeAuto("auto.ser"); //Print new attributes.

newFordZTW.print();

}

}


In: Computer Science

List the 4 reasons for process termination.

List the 4 reasons for process termination.

In: Computer Science

4.18 Using S-DES (see Appendix G on Blackboard), decrypt the string (10100010) using the key (0111111101)...

4.18 Using S-DES (see Appendix G on Blackboard), decrypt the string (10100010) using the key (0111111101) by hand. Show intermediate results after each function (IP, FK, SW, FK, IP-1). Then decode the first 4 bits of the plaintext string to a letter and the second 4 bits to another letter where we encode A through P in base 2 (i.e., A = 0000, B = 0001, …, P = 1111). Hint: As a midway check, after the application of SW, the string should be (00010011)

In: Computer Science

1. Explain the difference between a closed-ended question, an open-ended question, and a probing question. When...

1. Explain the difference between a closed-ended question, an open-ended question, and
a probing question. When would you use each?
2. Explain the difference between a top-down and bottom- up interview approach. When
would you use each approach?
3. Draw a use case diagram for the following dentist office system, but do not bother to
identify the flow of events within each use case. Whenever new patients are seen for
the first time, they complete a patient information form that asks their name,
address, phone number and brief medical history, which are stored in the patient
information file. When a patient calls to schedule a new appointment or change an
existing appointment, the receptionist checks the appointment file for an available
time. Once a good time is found for the patient, the appointment is scheduled. If the
patient is a new patient, an incomplete entry is made in the patient file; the full
information will be collected when they arrive for their appointment. Because
appointments are often made so far in advance, the receptionist usually mails a
reminder postcard to each patient two weeks before their appointment.
4. Create an activity diagram for the dentist office system in previous question.
5. Create one detail use-case description for the dentist office system in previous
question.

In: Computer Science

C++ Programming Consider an input file that lists test participants in alphabetical order and their scores....

C++ Programming

Consider an input file that lists test participants in alphabetical order and their scores. Each line has the following format:

LastName FirstName score

Load the input file into an array of structs, knowing there is a maximum of 50 participants. Output to output.txt the participants with the top 5 scores, in decreasing order of scores. Each output line should have the following format:

FirstName,LastName,score

Notes:

  • The name of the input file is acquired through standard input.
  • If the file does not exists, print the message "File not found!" in output.txt.
  • The output file must be named output.txt.
  • In case of a tie, output participants with the same score in alphabetical order.
  • If there are less than 5 participants, output all of them in decreasing order of scores.

Example input file:

Baker Alex 90
Eaves Pat 100
Kay Ivy 100
Lamar Jay 80,
O'Conor Ashton 95
Saber Alice 98
Sabin Chris 89
Valdez Daniel 99
Valko Pete 92

Example output file:

Pat,Eaves,100
Ivy,Kay,100
Daniel,Valdez,99
Alice,Saber,98
Ashton,O'Conor,95

#include <iostream>
using namespace std;

struct participant
{
string fname;
string lname;
int score;
};

int main() {

/* Type your code here. */

return 0;
}

In: Computer Science

In a file called NumbersToMonths.java, write a program that: Asks the user to specify a month...

In a file called NumbersToMonths.java, write a program that:

  • Asks the user to specify a month as an integer between 1 and 12. It is OK for your program to crash when the user does not enter a valid integer.
  • Prints out the name of the corresponding month.
  • Prints out "This number does not correspond to a month." if the integer is less than 1 or greater than 12.

For example: if the user enters 1, your program output should look EXACTLY like this:

Please indicate a month as an integer from 1 to 12: 1
January

In: Computer Science

Write a program that prompts the user to enter a 3 x 3 matrix of double...

Write a program that prompts the user to enter a 3 x 3 matrix of double values and tests whether it is a positive Markov matrix. There will be two methods which will be called from the main method: public static double [] [] createArray() 1. Creates a 3 by 3 two dimensional array of doubles 2. Prompts the user for values as shown in the sample run 3. Stores the numbers in the array in the order entered 4. Returns the array to the main method public boolean isMarkovMatrix(double [][] matrix) 1. Returns false if any value in the array is negative 2. Prints the sum of each column in the array 3. Returns false if any the sum of any of the columns is not equal to 1.0 4. Otherwise, it returns true.

In: Computer Science

Before C++ and classes, strings were stored in simple arrays of characters. The term C-string refers...

Before C++ and classes, strings were stored in simple arrays of characters. The term C-string refers to the classic implementation of strings in the C programming language. A C-string is a sequence of characters terminated by the null character, '\0'. Since C is part of C++, C-string implementations are valid in C++ as well as C. Recall that an array of characters is the underlying data structure for storing C-strings. For example, this definition creates such an array.

char myString[100];

myString will be capable of holding a C-string with up to 99 characters before the terminating null character. Of course, myString can hold a shorter C-string, too. For example, these assignments give myString the value "xyz".

myString[0] = 'x';

myString[1] = 'y';

myString[2] = 'z';

myString[3] = '\0';

It is legal to initialize a string variable, like this.

char example[100] = "First value";

However, it is not legal to assign string variables, because you cannot assign to an entire array.

myString = "xyz";         // ILLEGAL: Cannot assign to an array

Furthermore, you cannot do comparisons like this.

if (myString == "xyz")

cout << "fantasy land" << endl;

The comparison myString == "xyz" is actually legal (it will compile, syntactically correct), but it will always evaluate to false (semantically incorrect). To handle these kinds of difficulties, programmers can rely on the C-string library. This library, which is part of every proper C++ installation, is an extensive collection of functions for handling C-strings.

Your Task

Your task in this assignment is to create your versions of the most commonly used standard string functions. Specifically, you should create these functions:

Your version

(use these for Lab3Proj3.h)

ISO C standard string functions

Specifications

int mystrlen( const char *s)

int strlen( const char *s)

Determines the length of the string s. Returns the number of characters in the string before the '\0'.

int mystrcmp( const char *s1, const char *s2)

int strcmp( const char *s1, const char *s2)

Compares the string s1 to the string s2. The function returns 0 if they are the s

char *mystrcpy( char *s1,

const char *s2)

char *strcpy( char *s1, const char *s2)

Copies the string s2 into the character array s1. The value of s1 is returned.

char *mystrcat( char *s1,

const char *s2)

char *strcat( char *s1, const char *s2)

Appends the string s2 to the end of character array s1. The first character from s2 overwrites the '\0' of s1. The value of s1 is returned

Each of your functions should have the same behavior as the corresponding ISO C standard string function. For example, your mystrlen() function should have the same behavior as the ISO C standard strlen() function.

Your functions should not call any of the standard string functions. In the context of this assignment, you should pretend that the standard string functions do not exist.

You should pay special attention to boundary cases. In particular, make sure that your functions work when given empty strings as arguments. For example, make sure that the function call mystrlen("") returns 0.

You need to create a header file named Lab3Proj3.h containing the implementation of the four functions, that is, a set of function definitions. Your Lab3Proj3.cpp file must also #include this header.

You may use array notation to define your functions. For example, this is an acceptable version of the mystrlen() function:

int mystrlen( const char pcString[ ] )

{

int Length = 0;

while ( pcString[Length] != '\0' )

Length++;

return Length;

}

However we encourage you to use pointer notation instead of array notation to define your functions; pointer notation is used heavily throughout the course, and it would be wise to use this assignment to insure that you are comfortable with it. For example, we encourage you to define your mystrlen function similar to this:

int mystrlen( const char *pcString )

/* Return the length of string pcString. */

{

const char *pcStringEnd = pcString;

while ( *pcStringEnd != '\0' )

pcStringEnd++;

return pcStringEnd - pcString;

}

The comment should appear in the function as above. Note that the comment explicitly states what the function returns, and explicitly refers to the function's parameter (pcString).

We provide a driver file Project3driverWindow.cpp that you can download and use for testing your code. If no error outputs, your program passes all the tests. Otherwise, it will tell you the line numbers of errors in your source codes.

In: Computer Science

Write a program that asks the user to enter 3 grades and computes the minimum and...

Write a program that asks the user to enter 3 grades and computes the minimum and the maximum of those 3 grades and prints it. Hint: Use the Math.min() and Math.max() methods. This program will compute the smallest and highest of 3 grades entered by the user.

Enter 3 grades separated by a space: 100 85.3 90.5

Smallest: 85.3

Highest: 100.0

Bye

In: Computer Science