Questions
C++ Write a menu based program for the pet rescue. There should be 2 menu options...

C++

Write a menu based program for the pet rescue. There should be 2 menu options

-Add a pet

-View pets

-If the user chooses option 1, you will open a data file for writing without erasing the current contents, and write a new pet record to it. The file can be formatted any way that you choose but should include the pet's name, species, breed, and color. You my also include any additional information you think is appropriate.

-If the user chooses option 2, you will open your data file for reading and print the information all the pets to the screen.

-Once you have completed the actions of the chosen option, return to the main menu and ask if the user would like to quit or perform another task.

In: Computer Science

You come across three people. P says, “If Q is lying, then so is R,” Q...

You come across three people. P says, “If Q is lying, then so is R,” Q says, “If R is lying, then so is P,” and R says, “If P is lying, then so is Q.” Who if anyone is telling the truth?

In: Computer Science

Write a Python program with correct indentation using functions and mainline logic which prompts the user...

Write a Python program with correct indentation using functions and mainline logic which prompts the user to enter a number, then generates that number of random integers and stores them in a list. It should then display the following data to back to the user:

  • The list of integers
  • The lowest number in the list
  • The highest number in the list
  • The total sum of all the numbers in the list
  • The average number in the list
  • At a minimum, the numbers should range from 0 to 50, but you can use any range you like.

In: Computer Science

Purpose This assignment should give you experience in using file descriptors, open(), close(), write(), stat() and...

Purpose

This assignment should give you experience in using file descriptors, open(), close(), write(), stat() and chmod(), perror(), and command line arguments.

Program

Write a C++ program that will allow you to add messages to a file that has NO permissions for any user.

A Unix system has many files that have sensitive information in them. Permissions help keep these files secure. Some files can be publicly read, but can not be altered by a regular user (ex.: /etc/passwd). Other files can't be read at all by a regular user (ex.: /etc/shadow).

The program you develop should take a message given as a command line argument and append it to a file (also specified on the command line). The file should have no permissions, both before and after the message is appended. Of course, the file should be owned by you.

Your program should also have a -c option that will clear the file before the message is appended.

Algorithm

  1. Check to see if the output file exists. If it doesn't, create it. Life is simpler if a newly created file is closed at the end of this step.
  2. Check the permissions of the output file. If any permissions exist, print a useful error message and exit.
  3. Change the permissions on the file to allow writing by the user.
  4. Open the file for output. If the "-c" command line option is present, make sure the file is truncated.
  5. Write the message from the command line to the output file. Write an additional newline character so that the output has a nicer format.
  6. Clear the permissions and close the file. (These two operations can be performed in either order, but the implementation is slightly different.)

Useful Hints

  • Don't use the command line arguments directly. Their position in the argument list may change depending on options. Create meaningful char* variables and fill these with the appropriate entries from the argument list.
  • Check for error values after nearly every system function call. It's a pain to set up, but it saves time in the long run.

Input

None, really. Just command line arguments.

Error Checking

If the log file cannot be opened, an appropriate error message should be printed and the program should exit. If the file has any permissions at all, the file should be rejected as insecure, and the program should exit.

Example Run

Your program executable is called "z123456" here.

% rm log
% ./z123456
Usage: seclog [-c] out_file message_string
       where the message_string is appended to file out_file.
       The -c option clears the file before the message is appended
% chmod u-w .
% ./z123456 log "Hello"
Permission denied
% chmod u+w .
% ./z123456 log "Hello"
% ls -l
total 72
---------- 1 z123456 student     6 Sep 24 18:39 log
-rwxr-xr-x 1 z123456 student 26385 Sep 24 18:38 z123456
-rw-r--r-- 1 z123456 student  2204 Sep 24 18:36 z123456.cxx
-rw-r--r-- 1 z123456 student 30896 Sep 24 18:38 z123456.o
% ./z123456 log "Hello"
% ls -l
total 72
---------- 1 z123456 student    12 Sep 24 18:40 log
-rwxr-xr-x 1 z123456 student 26385 Sep 24 18:38 z123456
-rw-r--r-- 1 z123456 student  2204 Sep 24 18:36 z123456.cxx
-rw-r--r-- 1 z123456 student 30896 Sep 24 18:38 z123456.o
% chmod 400 log
% tail log
Hello
Hello
% ./z123456 log "Wait, there's more"
log is not secure.  Ignoring.
% chmod 000 log
% ./z123456 log "Wait, there's more"
% ls -l
total 72
---------- 1 z123456 student    31 Sep 24 18:41 log
-rwxr-xr-x 1 z123456 student 26385 Sep 24 18:38 z123456
-rw-r--r-- 1 z123456 student  2204 Sep 24 18:36 z123456.cxx
-rw-r--r-- 1 z123456 student 30896 Sep 24 18:38 z123456.o
% chmod 400 log
% tail log
Hello
Hello
Wait, there's more
% chmod 000 log
% ./z123456 -c log "Clean start"
% ls -l
total 72
---------- 1 z123456 student    12 Sep 24 18:41 log
-rwxr-xr-x 1 z123456 student 26385 Sep 24 18:38 z123456
-rw-r--r-- 1 z123456 student  2204 Sep 24 18:36 z123456.cxx
-rw-r--r-- 1 z123456 student 30896 Sep 24 18:38 z123456.o
% chmod 400 log
% tail log
Clean start
% chmod 000 log
%

In: Computer Science

Java Chapter 12.29 (Rename files) suppose you have a lot of files in a directory named...

Java Chapter 12.29 (Rename files) suppose you have a lot of files in a directory named Exercisei_j, where i and j are digits. Write a program that pads a 0 before j if j is a single digit. For example, a file named Exercise2_1 in a directory will be renamed to Exercise2_01. In Java, when you pass the symbol * from the command line, it refers to all files in the directory (see Supplement III.V). Use the following command to run your program. java Exercise12_29 * can you make a example directory with sample files.. Please type you answer. Thanks

In: Computer Science

How would I fix my coding to allow the user to see what they have entered...

How would I fix my coding to allow the user to see what they have entered after they submit it? Where would I plug it into my code to see it?

<!Doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Login and Registeration Form Design</title>
<link rel="stylesheet" type="text/css" href="../signintrial.css">


<script>

function loginHandler(){
// code for handing login event
}

function registerHandler() {
  
//checking phone number
  
if(phonenumber(document.getElementById('phone').value))
  
{
  
//when phone number is valid
  
document.getElementById('demo').innerHTML = document.getElementById('fname').value + " " + document.getElementById('lname').value + " " + document.getElementById('street').value + " " + document.getElementById('city').value + " " + document.getElementById('zcode').value + " " + document.getElementById('email').value + " " + document.getElementById('phone').value + " " + document.getElementById('username').value + " " + document.getElementById('password').value;
  
}
  
  
  
}
  
//function to validate phone number
  
function phonenumber(inputtxt) {
  
//regular expression for phone number
  
var phoneno = /^ ( \( \d{3}\) | \d{3} ) [-\s] \d{3} -\d{4} /;
  
//checking phone number
  
if (inputtxt.match(phoneno)) {
  
//when phone number is valid
  
return true;
  
}
  
function loginHandler(){
// code for handing login event
}

function registerHandler() {
  
//checking phone number
  
if(phonenumber(document.getElementById('phone').value))
  
{
  
//when phone number is valid
  
document.getElementById('demo').innerHTML = document.getElementById('fname').value + " " + document.getElementById('lname').value + " " + document.getElementById('street').value + " " + document.getElementById('city').value + " " + document.getElementById('zcode').value + " " + document.getElementById('email').value + " " + document.getElementById('phone').value;
  
}
  
  
  
}
  
//function to validate phone number
  
function phonenumber(inputtxt) {
  
//regular expression for phone number
  
var phoneno = /^ ( \( \d{3}\) | \d{3} ) [-\s] \d{3} -\d{4} /;
  
//checking phone number
  
if (inputtxt.match(phoneno)) {
  
//when phone number is valid
  
return true;
  
}
  
else{
  
// No need to use this anymore as error is shown through HTML
// alert("Phone number is invalid!");//alert to the user
  
return false;
  
}
  
  
  
}
  
  
</script>


</head>
<body>

<!--Adding Login and Registeration as two different divisions with different class names-->
<!--Registration is also implemented using form tag-->
<!--Both the forms on submission have been handled by separate functions in the javascript-->
<!-- onclick="loginHandler()" for login form -->
<!-- onclick="registerHandler()" for register form -->
<!--To get the similar alert for incorrect password pattern, using the form tag will help-->
  
<!--added a new division for login section-->
<div class="login-section">
<h1> Login </h1>
<form action="" method="post">
Username:<input type="text" id="username" name="username" minlength="4" maxlength="20" required><br><br>
Password:<input type="password" id="password" name="password" required pattern="(?=.*\d)(?=.*[@$!?])(?=.*[a-z])(?=.*[A-Z]).{4,12}" title="Must contain at least one number and one uppercase and lowercase and one special character from this list[@$!?], and length between 4 to 20"><br><br>
<input type="submit" onclick="loginHandler()" value="Submit">
</form><br>
</div>

<!--changed the class name to register-section from login-page-->
<div class="register-section">


<!-- Added this form tag to get the HTML5 error alert if phone number has not matched-->
<form>
<br>
<h1> Register </h1>
               <input type="text" id="fname" placeholder="first name" /><br><br>
<input type="text" id="lname" placeholder="last name" /><br><br>
<input type="text" id="street" placeholder="street address" /><br><br>
<input type="text" id="city" placeholder="city" /><br><br>
<input type="text" id="zcode" placeholder="zip code" /><br><br>
<input type="text" id="email" placeholder="email address" /><br><br>
<!--added title attribute to show on error-->
<input type="text" id="phone" value="" pattern="(\(\d{3}\)|\d{3})[-\s]\d{3}-\d{4}" placeholder="XXX-XXX-XXXX" required title="Phone number is invalid. Must contain all digits in the format XXX-XXX-XXXX"/><br><br>
<!-- changed the eventHandler name-->
<button onclick="registerHandler()">Create</button><br>
<label for="create login" id="create login"></label>
<p id="demo"></p>
</form>
</div>
</body>
</html>

In: Computer Science

Do a search for a product of your choice on two search engines. Examine the results...

Do a search for a product of your choice on two search engines. Examine the results page carefully. Can you distinguish which results, if any, are a result of a paid placement? If so, how did you determine this? What other marketing communications related to your search appear on the page?

In: Computer Science

DATABASE MANAGEMENT SYSTEMS After looking at the material in Section 2, go ahead and answer the...

DATABASE MANAGEMENT SYSTEMS

After looking at the material in Section 2, go ahead and answer the following questions:

  • What is a foreign Key? (1 Point)
  • What is a composite attribute? Give an example (1 Points)
  • What is a multivalued attribute? Give an example (1 Points)
  • What is a relationship Modality? What is a relationship Cardinality? (2 Point)

(Make sure you understand the difference between the two)

  • Open MySql workbench and build an ERD with the following Entities, Attributes and Relationships.

We want to track historical data of Soccer players. We want to track current data for clubs, Coaches and Soccer Balls.

A soccer player can only play for one club but over time a player would have played for one or many clubs. A club has many players.

Some players are Captains and supervise other players.

A club can have one or many Coaches, a Coach can only coach one team.

A Team has one or many soccer balls, a Soccer ball can only belong to one team. (10 Points)

Players

Teams

Coaches

Soccer Balls

To be defined

Player ID

Team ID

Coach ID

Serial Number

…..

First Name

Team Name

C_FirstName

Maker

…..

Last Name

City

C_LastName

Color

…..

Address1

Phone

City

State

Zip Code

Country of Origin

In: Computer Science

Give an example of a linear system of three equations with three unknowns that has the...

Give an example of a linear system of three equations with three unknowns that has the general solution with one parameter.

In: Computer Science

Write a boolean function that is given a binary tree and returns true if and only...

Write a boolean function that is given a binary tree and returns true if and only if the tree has an odd number of nodes. An empty tree is considered to have an even number of nodes. Notes: The function should have just one argument, a pointer to the root. No global variables may be used. No additional functions may be defined. You may not count the number of nodes.

In: Computer Science

Create a python program that: Creates a sales receipt, displays the receipt entries and totals, and...

Create a python program that:

  • Creates a sales receipt, displays the receipt entries and totals, and saves the receipt entries to a file
    • Prompt the user to enter the
      • Item Name
      • Item Quantity
      • Item Price
    • Display the item name, the quantity, and item price, and the extended price (Item Quantity multiplied by Item Price) after the entry is made
    • Save the item name, quantity, item price, and extended price to a file
      • When you create the file, prompt the user for the name they want to give the file
      • Separate the items saved with commas
      • Each entry should be on a separate line in the text file
    • Ask the user if they have more items to enter
  • Once the user has finished entering items
    • Close the file with the items entered
    • Display the sales total
    • If the sales total is more than $100
      • Calculate and display a 10% discount
    • Calculate and display the sales tax using 8% as the sales tax rate
      • The sales tax should be calculated on the sales total after the discount
    • Display the total for the sales receipt

In: Computer Science

in java Write a Java Program that displays a menu with five different options: 1. Lab...

in java

Write a Java Program that displays a menu with five different options:

1. Lab Test Average Calculator

2. Dice Roll

3. Circle Area Calculator

4. Compute Distance

5. Quit The program will display a menu with each of the options above, and then ask the user to enter their choice. There is also a fifth option to quit, in which case, the program will simply display a goodbye message. Based on the user’s choice, one of the options will be shown. Make sure to include proper output in all cases (such as instructions, questions to the user, or directions telling the user to input something specific). Lab Test Average Calculator: Prompts the user to enter the grades for three Lab Tests. The program then calculates the average of all 3 lab tests and displays the result. Note: For example, if the user inputs: 80, 60, 95 the result should be 78.33 and not 78.0. Be sure to use the appropriate data types for this option. Dice Roll: The program simulates a dice roll by generating a random integer between 1 and 6. The user is then prompted to guess whether the dice value is even or odd. If the user guess matches the evenness/oddness of the dice, a victory message is displayed, otherwise, a loss message is displayed. Circle Area Calculator: Prompts the user to enter the radius, then calculates the circle’s area using the formula (3.14*radius2 πr ). 2 Compute Distance: The user is prompted to enter the x and y coordinates for two points (x1 , y1 and x2 , y2 ). The program then computes and displays the distance between the two user-inputted points. The formula for computing the distance is √(x ) (y ) . 2 − x 1 2 + 2 − y 1 2 Note that you can use Math.pow(a, 0.5) to compute √a . Make sure your code is well commented with well defined steps. You cannot use any sort of Java API methods other than the Scanner for this program.

In: Computer Science

PYTHON Exercise 4. Fantasy Game Inventory Imagine you have this inventory in a fantasy game: Item...

PYTHON Exercise 4. Fantasy Game Inventory Imagine you have this inventory in a fantasy game: Item Number of this items Rope 1 Torch 6 Gold coin 42 Dagger 1 Arrow 12 1. Save the inventory in a data structure. 2. Write a function that will take any possible inventory and display it in a pretty format. 3. Write a function to add new items to the data structure. Make sure new group of items can be created. 4. Write a function to delete items (not a whole group) from the data structure.

In: Computer Science

Using brackets you will need to create the HTML page and CSS style sheet for the...

Using brackets you will need to create the HTML page and CSS style sheet for the given Form example.

  1. Form 1: create an HTML page with a form that contains a text input field. The label for the text field should be “City”. Beneath it should be a submit button “Lookup”. Place a horizontal line beneath the Lookup button and add three radio buttons labeled “Beginner”, “Intermediate”, and “Advanced”.

Your page should have a title and a header in the body.

  1. Requirements for styling:
    1. The form should have a light grey background color (#eee).
    2. The form font should be 10pt Arial
    3. The form padding should be 10px
    4. For the text field <label> tag, set display to inline-block, use a width of 55px, align the text to the left, and add a margin on the right of 9px.
    5. For the text input, add a 290px width, 14px padding, and 8px margin on top.
    6. For the button, add a 1px solid gray border, 190px width, 12px padding, and 6px margin on top. The button should change color when the mouse is hovering over it.
    7. For all labels and adjacent radio buttons, use a pointer cursor, a margin of 25px to the right, and font size of 15pt.

In: Computer Science

Write a C program that calculates the average grade for a specified number of students from...

Write a C program that calculates the average grade for a specified number of students from each student's test1 and test2 grades. The program must first ask the user how many students there are. Then, for each student, the program will ask the user for the test1 grade (grade #1) and test2 grade (grade #2). The program should be able to handle up to 100 students, each with 2 grades (test1 and test2). Use a two-dimensional float array to store the grades. Then, using a loop, prompt the user for the test1 and test2 grade of each student. Create a second single-dimensional float array to hold the average grade for each student (for up to 100 students). To calculate the average grade, pass both the two-dimensional array and the single-dimensional array to a function named void calculateAverages(float grades[][2], float averages[], int numStudents). The third parameter of the function indicates the actual number of students. The function will then use a loop to calculate the average grade for each student. Remember, since averages is an array parameter, any changes to averages is changing the original array. When the function returns to main, the program (in main) should display the average grade for each student (using a loop).

In: Computer Science