Questions
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

need to add this withdrawal and balance function to the script below: Calculate the Balance -...

need to add this withdrawal and balance function to the script below:

Calculate the Balance - Withdrawal

If the action is Withdrawal ‘W’, use the withdrawal function to remove funds from the account

Hint – The formatter for a float value in Python is %f. With the formatter %.2f, you format the float to have 2 decimal places. For example:

print("Account balance: $%.2f" % account_balance)

Withdrawal Information

Withdraw Input

userchoice = input ("What would you like to do?\n")
userchoice = 'W'
withdrawal_amount = 100

Withdraw Output

What would you like to do?
How much would you like to withdraw today?
Withdrawal amount was $100, current balance is $600.25

ATM Summary Feedback Available

If you would like our automated system to review your code and give you some feedback on your project before you submit for a grade, just click the Help Me! button below.

Help Me!

  1. You will need to define a function called withdrawal.
  2. Request from the user the amount to be withdrawn. This value should be stored in a variable called withdrawal_amount. Use both the input and float methods in order to ensure the withdrawal_amount is a float value
  3. Ensure the withdrawal_amount is not greater than the account_balance.
    1. If the withdrawal_amount is greater than the `account_balance`, print the following message:

      withdrawal_amount is greater than your account balance of account_balance

      Ensure you display the withdrawal amount and the account balance with the '$' and two decimal points.
  4. If the withdrawal amount is less than or equal to the account_balance then calculate a new account balance.
  5. The calculation for withdrawing funds from the account is account_balance = account_balance - withdrawal_amount
  6. Print print the following message:

    Withdrawal amount was withdrawal_amount, current balance is account_balance

Need to add the Withdrawal amount to this program:

import sys # importing the sys library

# account balance

account_balance = float(500.25)

# PPrint the balance

# This is a custom function, it returns the current balance upto 2 decimal places

def printbalance():

print('Your current balance:')

return account_balance

# the function for deposit

# This is a custom function

def deposit():

# takes in input for deposit amount

deposit_amount = float(

input("How much would you like to deposit today?\n"))

balance = account_balance + deposit_amount # calculates balance

print("Deposit was $%.2f, current balance is $%.2f" %

(deposit_amount, balance)) # prints out the balance

# function for withdraw

# this is a custom function

def withdraw():

# takes in the withdraw amount

withdraw_amount = float(input("Enter amount to withdraw"))

if(withdraw_amount > account_balance): # checks whether the amount is more than balance or not

print("$%2f is greater than account balance $%2f\n" %

(withdraw_amount, account_balance)) # if yes then

else:

balance = account_balance - withdraw_amount

print("$%2f was withdrawn, current balance is $%2f" %

(withdraw_amount, balance))

# User Input goes here, use if/else conditional statement to call function based on user input

userchoice = input("What would you like to do?\n")

if (userchoice == 'D'):

# here deposit function is called

deposit()

elif userchoice == 'W':

# here withdraw function is called

withdraw()

elif userchoice == 'B':

# here printbalance function is called

balance = printbalance()

print('{:.2f}'.format(balance))

else:

# it ends the program execution

sys.exit()


calculate the balance and withdrawal or should i say incoorporate it in to script.

In: Computer Science

Suggest an appropriate project methodology that might be used for development of the following computer systems....

Suggest an appropriate project methodology that might be used for development of the following computer systems. Provide proper justification of your choice.

  • The traffic control system inside Riyadh city is not meeting the expectations of traffic police. The system is to be updated within a few weeks to incorporate the traffic intensity, the weather conditions and the VIP movements etc. Suggest an appropriate software model for this scenario.
  • A social network web application (a Facebook-like application)

In: Computer Science

Banks issue credit cards with 16 digit numbers. If you've never thought about it before you...

Banks issue credit cards with 16 digit numbers. If you've never thought about it before you may not realize it, but there are specific rules for what those numbers can be. For example, the first few digits of the number tell you what kind of card it is - all Visa cards start with 4, MasterCard numbers start with 51 through 55, American Express starts with 34 or 37, etc. Automated systems can use this number to tell which company to contact without having to "look" at the card itself and see what the bank is on it.

Another key part of the credit card number standard is the check digit. The last digit of every credit card number is determined by the previous 15 digits through a simple mathematical formula known the Luhn Algorithm. The Lhun Algorithm can be used to check if a credit card number has been corrupted in its transmission between the vendor reading the card, and the bank which has the account. It can also be used to check to see if a credit card number is valid before transmitting it to the bank.

The Luhn Algorithm is described at the link above, but the basic idea is:

From the right-to-left, double the value of each digit that is in an even-numbered position (with the check-digit at position 1). If this doubling gives you a two-digit value for any of the numbers, then subtract 9 from the value (which is easier than adding the digits together but gets you the same result). Leave the odd-valued positions as is.
Sum together all of the values except the check digit.
Take the digit in the one's position of the sum. If the value of that digit is 0, then it stays as 0. If the value is greater than zero, subtract that value from 10. That value should be the check digit (note that the special case for 0 is required since "10" is not a single digit).
For example, suppose the card you want to validate is: 5457623898234113. In this case the check-digit is 3 and the remaining digits are the 15-digit account number. We can confirm that we likely have a good card number by validating the check digit as follows:

Position 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1
Original Value 5 4 5 7 6 2 3 8 9 8 2 3 4 1 1 3
Doubled value 10 10 12 6 18 4 8 2
Doubled-value adjusted 1 1 3 6 9 4 8 2
Sum of values = 67 1 4 1 7 3 2 6 8 9 8 4 3 8 1 2
Check digit is 3 (10 - 7 = 3)
You can read more about credit card numbers, as well as how the Luhn Algorithm is used in other areas of Computer Science, in this article from the Data Genetics blog (where the above example was taken from).

For this lab you will write a Java program that checks credit card strings to see if they are valid. Your program should first prompt the user to enter a string of numbers as a credit card number, or enter a blank line to quit the program. If the user doesn't quit, your program should ensure that this string is exactly 16 characters in length. If the user enters a string that is not 16 characters in length, your program should print an error message and ask again for a valid string. Your program should use the Luhn Algorithm above to compute what the check digit should be and then compare it to the actual value in the provided string and report whether the credit card number is valid or wrong. If it is wrong, your program should report what the correct check digit should be for the input value. Your program should keep asking for new values until the user enters a blank line to quit the program.

Create a new project named LuhnAlgorithm and a new Java program in that project folder named LuhnAlgorithm.java for this project. You can find a selection of valid-but-fake credit card numbers courtesy of PayPal at this link. Change the check digit on any of them to get an invalid number (note that your code should only use the 16 digit numbers and does not have to account for any of the card numbers that have any number of digits other than 16).

NOTE: You do NOT need to use arrays to solve this problem - this problem can be solved just with nested loops. Solutions that use an array where it isn't needed will be penalized in two ways: First, you're making the problem much harder than it needs to be, and second there will be a point deduction for use of an unnecessary array in the solution.

Sample Output: This is a sample transcript of what your program should do. Items in bold are user input and should not be put on the screen by your program.

Enter a credit card number (enter a blank line to quit): 5457623898234112
Check digit should be: 3
Check digit is: 2
Number is not valid.

Enter a credit card number (enter a blank line to quit): 5457623898234113
Check digit should be: 3
Check digit is: 3
Number is valid.

Enter a credit card number (enter a blank line to quit): 5555555555554
ERROR! Number MUST have exactly 16 digits.

Enter a credit card number (enter a blank line to quit): 5555555555554445
Check digit should be: 4
Check digit is: 5
Number is not valid.

Enter a credit card number (enter a blank line to quit):
Goodbye!
Note: You will need to convert characters in your string into integer values to make this project work. There are two ways to do this. The first is to use Integer.parseInt and substring to get a character value. The following lines of code would give you the integer value of the first character of the string input:

String s = input.substring(0,1);
int val = Integer.parseInt(s);
Another way to get a numeric value from a character is to use the method Character.getNumericValue. This takes a char value (not a String) and converts it to its correct integer value. The following lines of code would give the integer value of the first character of the String input:

char c = input.charAt(0);
int val = Character.getNumericValue(c);

In: Computer Science

Distinguish between logical models and physical models. How is each useful?

Distinguish between logical models and physical models. How is each useful?

In: Computer Science

Modify your program from Learning Journal Unit 7 to read dictionary items from a file and...

Modify your program from Learning Journal Unit 7 to read dictionary items from a file and write the inverted dictionary to a file. You will need to decide on the following:

  • How to format each dictionary item as a text string in the input file.
  • How to covert each input string into a dictionary item.
  • How to format each item of your inverted dictionary as a text string in the output file.

Create an input file with your original three-or-more items and add at least three new items, for a total of at least six items.

Copy your program from Part 1 and modify it to do the following:

  • Read the output file from Part 1 and create a dictionary from it (the inverted dictionary from Part 1).
  • Invert that dictionary.
  • Write the re-inverted dictionary to an output file.

It will be interesting to see if your original dictionary is reversible. If you invert it twice, do you get the original dictionary back?

Include the following in your Learning Journal submission:

  • The input file for your original dictionary (with at least six items).
  • The Python program for Part 1.
  • The output file for your inverted dictionary, which is also the input file for Part 2.
  • The Python program for Part 2.
  • The output file for your twice-inverted dictionary.
  • A description of any differences between your program for Part 1 and your program for Part 2.
  • A description of any differences between the original input file and the final twice-inverted output file.

Learning Journal Unit 7

Create a Python dictionary where the value is a list . The key can be whatever type you want.

Design the dictionary so that it could be useful for something meaningful to you. Create at least three different items in it. Invent the dictionary yourself. Do not copy the design or items from some other source.

Next consider the invert_dict function from Section 11.5 of your textbook.

# From Section 11.5 of:
# Downey, A. (2015). Think Python: How to think like a computer scientist . Needham, Massachusetts: Green Tree Press.

definvert_dict(d):
inverse = dict()
for key in d:
val = d[key]
if val not in inverse:
inverse[val] = [key]
else:
inverse[val].append(key)
return inverse

Modify this function so that it can invert your dictionary. In particular, the function will need to turn each of the list items into separate keys in the inverted dictionary.

Run your modified invert_dict function on your dictionary. Print the original dictionary and the inverted one.

Include your Python program and the output in your Learning Journal submission.

Describe what is useful about your dictionary. Then describe whether the inverted dictionary is useful or meaningful, and why.

In: Computer Science

Letter Separated Numbers (C++) I've encountered a corrupted database that has a series of important numbers,...

Letter Separated Numbers (C++)

I've encountered a corrupted database that has a series of important numbers, but instead of being separated by a space, the spaces have been randomly changed in alphabetic characters. Write a function named "my_numbers" that can take a string like "18y5638b-78" and return a vector of ints {18, 5638, -78}.

Thanks!

In: Computer Science

Write an inheritance hierarchy for classes Quadrilateral, Trapezoid, Parallelogram, Rectangle and Square. Use Quadrilateral as the...

Write an inheritance hierarchy for classes Quadrilateral, Trapezoid, Parallelogram, Rectangle and Square. Use Quadrilateral as the superclass of the hierarchy. Create and use a Point class to represent the points in each shape. Make the hierarchy as deep ( i.e., as many levels ) as possible. Specify the instance variables and methods for each class. The private instances variables of Quadrilateral should be the x-y coordinate pairs for the four endpoints of the Quadrilateral. Write a program that instantiates objects of your classes and outputs each object’s area (except Quadrilateral).

In: Computer Science

Using java: Implement a basic doubly-linked list that implements a priority system sorting the elements that...

Using java:

Implement a basic doubly-linked list that implements a priority system sorting the elements that are inserted. Sort based on the speed of the warrior.

Driver code:

public class LinkedListDriver {
public static void main(String[] args) {
LinkedList list = new SortedDoublyLinkedList();

System.out.println(list);
Warrior krogg = new Warrior("Krogg", 30, 50, 200);
list.insert(krogg);

System.out.println(list);
Warrior gurkh = new Warrior("Gurkh", 40, 45, 180);
list.insert(gurkh);

System.out.println(list);
Warrior brynn = new Warrior("Brynn", 45, 40, 190);
list.insert(brynn);

System.out.println(list);
Warrior dolf = new Warrior("Dolf", 20, 65, 210);
list.insert(dolf);

System.out.println(list);
Warrior zuni = new Warrior("Zuni", 50, 35, 170);
list.insert(zuni);

System.out.println(list);
}
}

Warrior class:

public class Warrior {
private String name;
private int speed;
private int strength;
private int hp;
public Warrior(String name, int speed, int str, int hp) {
this.name = name;
this.speed = speed;
this.strength = str;
this.hp = hp;
}

public String getName() { return this.name; }
public int getSpeed() { return this.speed; }
public int getStrength() { return this.strength; }
public int getHp() { return this.hp; }

public String toString() { return this.name + "(" +
this.speed + ")"; }
}

Class that needs to be done:
interface LinkedList {
void insert(Warrior warrior);
String toString();
}

Expected output:
[ Zuni(50) Brynn(45) Gurkh(40) Krogg(30) Dolf(20) ]

In: Computer Science

Design a universal hashing scheme using matrix operations.

Design a universal hashing scheme using matrix operations.

In: Computer Science

A survey of chewing gum preferences was given to baseball players. On the survey form, fruit...

A survey of chewing gum preferences was given to baseball players. On the survey form, fruit was checked a total of 21 times; spearmint was checked a total of 26 times; 12 players checked both; 7 surveys had nothing checked. How many players were surveyed?

In: Computer Science

2. Consider the following relations: Doctor(SSN, FirstName, LastName, Specialty,YearsOfExperience, PhoneNum) Patient(SSN, FirstName, LastName, Address, DOB, PrimaryDoctor_SSN)...

2. Consider the following relations:

Doctor(SSN, FirstName, LastName, Specialty,YearsOfExperience, PhoneNum)

Patient(SSN, FirstName, LastName, Address, DOB, PrimaryDoctor_SSN)

Medicine(TradeName, UnitPrice, GenericFlag)

Prescription(Prescription Id, Date, Doctor_SSN, Patient_SSN)

Prescription_Medicine(Prescription Id, TradeName, NumOfUnits)

Note: The Medicine relation has attributes, trade name, unit price, and whether or not the medicine is generic (True or False).

a. Determine the functional dependencies that exist in each table given above.

In: Computer Science