Questions
EXCEL VBA ABC company gives discount as follows: Purchase > $400                                

EXCEL VBA

  1. ABC company gives discount as follows:
    Purchase > $400                                                                     Discount rate = 5%
    Purchase between $300 and $400                                          Discount rate = 4%
    Purchase >= $100 and < $300                                              Discount rate = 2%
    Purchase < 100                                                                       No discount
    Purchase = Price * Quantity
    Discount = Purchase * Discount rate                                    
    Net Purchase = Purchase – Discount

Total Net Purchase is the running total of Net Purchases

Create a user interface form as shown below. Use text boxes to input price and quantity. Use labels to display the discount, net purchase (purchase amount after discount) and total net purchases. Click calculate button to calculate and display discount, net purchase, and total net purchases; click clear button to clear values from the text boxes and labels, except total net purchases; send the focus to the price text box.
Click exit button to end the application.

  1. Create a sub procedure in a module to calculate:
    a) the sum of even integers from 4 to 12 using DO WHILE. Display the sum in the message box. Name the sub procedure as Q2a.
    b) the sum of odd integers from 5 to 9 using FOR NEXT. Display the sum in message box. Name the sub procedure as Q2b.
  2. Create a sub procedure named as Question3 in a module to calculate the value and total value of items using a Do/while Loop. Value = Price * Quantity. Total value is the running total of values. Use INPUTBOX function to get the price and quantity. Display the value in the message box. Display total value in the message box after exiting the loop. Loop is entered by inputting “Y” at the prompt “Do you wish to continue?” and exited by entering “N” at the prompt “Do you wish to continue?”
  3. Create a sub procedure named as Question4 in a module to find the capital. Use INPUTBOX function to get the state and message box function to display the capital.

State                Capital

MN                   St.Paul

WI                   Madison

TX                   Austin

In: Computer Science

Write a method called printIsMultiple that receives a pair of integers and prints true if the...

  1. Write a method called printIsMultiple that receives a pair of integers and prints true if the second is a multiple of the first; false, otherwise

In: Computer Science

Q18. // This program finds the average time spent programming by a student // each day...

Q18.

// This program finds the average time spent programming by a student
// each day over a three day period.

// PLACE YOUR NAME HERE

#include 
using namespace std;

int main()
{
        int numStudents;
        float numHours, total, average;
        int student, day = 0;   // these are the counters for the loops

        cout << "This program will find the average number of hours a day"
                 << " that a student spent programming over a long weekend\n\n";
        cout << "How many students are there ?" << endl << endl;
        cin >> numStudents;

        for (student = 1; student <= numStudents; student++)
        {
                total = 0;

                for (day = 1; day <= 3; day++)
                {
                        cout << "Please enter the number of hours worked by student "
                                 << student << " on day " << day << "." << endl;
                        cin >> numHours;

                        total = total + numHours;
                }

                average = total / 3;

                cout << endl;
                cout << "The average number of hours per day spent programming by "
                         << "student " << student << " is " << average
                         << endl << endl << endl;
        }

        return 0;
}

Note that the inner loop of this program is always executed exactly three times—once for each day of the long weekend. Modify the code so that the inner loop iterates n times, where n is a positive integer input by the user. In other words, let the user decide how many days to consider just as they choose how many students to consider.

Sample Run:

This program will find the average number of hours a day that a student spent programming over a long weekend

How many students are there?
2
Enter the number of days in the long weekend
2

Please enter the number of hours worked by student 1 on day 1
4

Please enter the number of hours worked by student 1 on day 2
6

The average number of hours per day spent programming by student 1 is 5


Please enter the number of hours worked by student 2 on day 1
9

Please enter the number of hours worked by student 2 on day 2
13

The average number of hours per day spent programming by student 2 is 11

Q19. Modify the program from Q18 so that it also finds the average number of hours per day that a given student studies biology as well as programming. For each given student include two prompts, one for each subject. Have the program print out which subject the student, on average, spent the most time on.

In: Computer Science

Take into account robotic space exploration. Please describe why an engineer would decide to use C...

Take into account robotic space exploration. Please describe why an engineer would decide to use C or C++ over a higher level language such as Python? What are some benefit an object-oriented language have in comparison to a purely procedural language?

In: Computer Science

Q20. Using C++ style string to write a program that reads a sentence as input and...

Q20. Using C++ style string to write a program that reads a sentence as input and converts each word of the sentence following the rule below:

  • For every word in the sentence, the first letter is relocated the end of the word.
  • Then append the string “KPU” to the word.

More requirements:

  • All letters in the output should be uppercase.

More assumptions:

  • The input sentence contains no non-alphabetic letters

Sample Run:

Please enter the original sentence: i LOVE to program
Translated: IKPU OVELKPU OTKPU ROGRAMPKPU

In: Computer Science

You are hired to design a database for a fitness center. As the fitness center is...

You are hired to design a database for a fitness center. As the fitness center is expanding with more than one branch, they want to create a database to keep track of its customers, facilities and employees. Each branch has a unique id and address (building number, street, district, and city). A branch may have more than one facility (e.g. swimming pool, spa, etc.). Each facility must belong to only one branch, and the information for a facility is name and fees. In addition, each fitness branch offers different classes (such as Yoga, Pilates, Zumba, etc.). All classes should be led by at most one trainer, who is an employee.

Employees must work at one and only one branch. Each employee has an id, name, address (building number, street, district, and city) and can have multiple phone numbers. An employee can only be an admin, managing the facility or working as a clerk, or a trainer. An employee cannot be a trainer and an admin because the trainer id compensated an hourly wage while an admin staff paid a monthly salary. Trainers can train individual customers at different time sessions.

A customer must register at one branch. Each customer has a membership number, name (stored as first name and last name), email, and only one phone number. A customer can join more than one class or uses any number of facilities. A customer may also decide to be trained by at most one personal trainer.

Given the above description:

1. Draw a Chen's Notation ER Diagram for the database, identifying the following:

a.All the entities, attributes and relationships

b.Primary key and (discriminator in weak entity, if any). Don’t forget each entity has to have PK.

c.Participation and cardinality constraints. (Explain your choices for two constraints- i.e. identify the words the guided your decision)

d.Specialization and completeness constraints (if there is an ISA relationship).

2. Write a schema for two entities and two relationships of your choice. Remember, sometimes a relationship is better not be represented in a separate schema; if this is the case with your chosen relationship explain what you will do.

In: Computer Science

A multiple-choice examination consists of 20 questions. Each question has five choices, labeled A, B, C,...

A multiple-choice examination consists of 20 questions. Each question has five choices, labeled A, B, C, D and E. All data for that exam is stored in a file exam.txt. The first line of data contains the correct answers to the twenty questions in the first 20 consecutive (one after the other) character positions.
For Example: BECDCBAADEBACBEDDBED

Each subsequent line in the file contains the answers for a single candidate. Data on a line consists of a candidate number (an integer), then by one or more spaces, followed by the twenty answers given by the candidate in the next 20 consecutive character positions. An X is used if a candidate did not answer a particular question. A sample line is as follows:

5555 BECDCXACCAEDCBEDDACB

There can be an unlimited number of candidates. A line containing a “candidate number” 0 indicates the end of the data.

A student’s final score is calculated by adding up the points awarded for all the questions. Points for a question are awarded as follows:
• Correct answer 4 points
• Wrong answer -1 point
• No answer 0 points

Write a C# program to process the data in the file exam.txt and generate a report that shows:
1. Each candidate number and their final score (the total points obtained by the candidate).
2. The total number of candidates.
3. The number of correct responses to each of the 20 questions.
4. The minimum score attained by a student in the exam.
5. The maximum score attained by a student in the exam.
6. The average score attained by a student in the exam.

The report must be written to a file called Report.txt.

In: Computer Science

Write an Assembley Language.Given a number x, determine whether the given number is Armstrong number or...

Write an Assembley Language.Given a number x, determine whether the given number is Armstrong number or not. A positive integer of n digits is called an Armstrong number of order n(where order is the number of digits) if.

   abcd... = pow(a,n) + pow(b,n) + pow(c,n) + pow(d,n) + ....

Example:

  • Input : 153 Output : Yes, 153 is an Armstrong number. 1*1*1 + 5*5*5 + 3*3*3 = 153
  • Input : 120 Output : No, 120 is not a Armstrong number. 1*1*1 + 2*2*2 + 0*0*0 = 9
  • Input : 1253 Output : No, 1253 is not a Armstrong Number 1*1*1*1 + 2*2*2*2 + 5*5*5*5 + 3*3*3*3 = 723
  • Input : 1634 Output : Yes, 1*1*1*1 + 6*6*6*6 + 3*3*3*3 + 4*4*4*4 = 1634

HINT: Use the ReadString function found in the Irvine32 library to capture the user's input.

In: Computer Science

Your (turtle) program in python must include: Create four Red turtles and four Blue turtles using...

Your (turtle) program in python must include: Create four Red turtles and four Blue turtles using one or more lists. • Start each of the Red turtles at a different random location on the left side of the screen within the range of the square formed by (-100, 100) and (0, -100) and each of the Blue turtles at a random location on the right side of the screen within the range of the square formed by (0, 100) and (100, -100). • Each of the red and blue turtles should move randomly. • Draw a boundary for the game as a circle with a 300 unit radius. You will use an invisible turtle to do this. It does not count as one of the turtles on either team. • If a turtle hits the border the turtle should have its color changed to black and should jump back to the center of the screen (0, 0) and continue moving. • All the turtles will move the same speed. • The turtles should continue moving until 1000 time units have elapsed.

In: Computer Science

Python please Questions #3, #4 and # 5 please A string is one of most powerful...

Python please Questions #3, #4 and # 5 please

A string is one of most powerful data types in programming. A string object is a sequence of characters and because it is a sequence, it is indexable, using index numbers starting with 0. Similar to a list object, a string object allows for the use of negative index with -1 representing the index of the last character in the sequence. Accessing a string object with an invalid index will result in IndexError exception.

In Python a string literal is defined to be a sequence of characters enclosed in single, double or triple quotes.

To define a string object or variable, we use one of the following:

  1. strObj = string_literal
  2. strObj = str(any object)
  3. strObj = str() or strObj = ‘’, strObj = “”, strObj = ‘’’’’’ , an empty string

A string object in immutable, meaning, it cannot be changed once it is defined.

The concatenation operator (+) is used to add two or more string objects (strObj1 + strObj2)

The repetition operator (*) is used to repeat the string object (n*strObj or strObj*n, where n is an integer)

The in and not in operators are used to test if one string object is contained in another string object.

Slice a string object using strObj[start:end], start is the index of the starting character and end-1 is the index last character.

The split method creates a list of the split string object.

lstObj = strObj.split(split-character)

space is the default split-character.

The strip method removes the leading and trailing character, the default is space.

strObj.strip(strip-character)

Variations: rstrip, lstrip (left and right strip methods to remove leading and trailing character, respectively)

Other commonly used string methods are

strObj.lower() changes all characters to lowercase

strObj.upper() changes all characters to uppercase

strObj.islower() tests if all characters are lowercase

strObj.isupper() tests if all characters are uppercase

strObj.replace(old, new) replaces old substring with new substring

strObj.find(substring) returns the lowest index of the substring if it is found in strObj

Activity

  1. Write a program to reverse a string object
  2. Write a program that will check if a string object is a palindrome, that is a word, phrase, or sequence that reads the same backward as forward, e.g., madam or nurses run. Note: reverse(string) = string.
  3. Define a string object that will hold “department computer science:fayetteville state university:fayetteville, north carolina”
  4. Split the string object in (3) using the character “:” and assign to a list object
  5. Write a program that capitalize the first letter of every word in string object in (3)
  6. Write a program that insert the string objects “of” and “28301” to the new string object in (5)
  7. Write a program that will display the word, character, space counts in the file storytelling.txt.(The file is on Canvas in the Worksheets folder).

In: Computer Science

Create a new folder called CSCI130_A3_yourname. Create all of the files indicated below within this folder....

Create a new folder called CSCI130_A3_yourname. Create all of the files indicated below within this folder.

For this assignment you will be creating a total of 2 classes that meet the definitions below. This assignment will allow the user to enter in the coefficients for a polynomial function of degree 2. The user will then be asked to enter a number. The program will use that number as an argument to the function, and will print the corresponding function value.

Keep in mind that a second degree polynomial function in general form looks like:

    f(x) = ax2 + bx + c (here 'a' is the coefficient of the quadratic term, 'b' is the coefficient of the linear term, and 'c' is the constant)

Refer to the image at the bottom of this page to get a better understanding of the logic flow.

CLASSES:

  1. Polynomial - this class should be in a file named Polynomial.java
  2. Assignment3 - this class should be in a file named Assignment3.java

CLASS DEFINITIONS:

class Polynomial

Data (instance variables) - all have private access

  • double quadraticCoefficient (this is the coefficient of the quadratic term of the polynomial)
  • double linearCoefficient (this is the coefficient of the linear term of the polynomial)
  • double constant (this is the constant of the polynomial)

Methods (behaviors) - all have public access

constructor:

  • Arguments:
    • None
  • Return
    • None
  • Behavior
    • Calls Polynomial's constructPolynomial instance method

constructPolynomial:

  • Arguments:
    • None
  • Return
    • None
  • Behavior
    • Allows user to enter the necessary coefficients and the constant term for the polynomial, and sets the attributes accordingly

functionValue:

  • Arguments:
    • double arg
  • Return
    • double
  • Behavior
    • Calculates and returns the function value using the argument arg (for example, if the user entered the polynomial 3x2 + 2x + 7, then functionValue(3) would return 40)

displaySelf:

  • Arguments:
    • None
  • Return
    • None
  • Behavior
    • Neatly displays the polynomial entered by the user

class Assignment3

Methods

public static void main(String[] args):

  • Arguments:
    • String[] args
  • Return:
    • None
  • Behavior (see image below for clarification):
    • The polynomial is constructed
    • The user is asked for the argument to the function
    • The polynomial is displayed
    • The function value (based on the argument and Polynomial entered) is displayed

After writing the code, do the following:

  • Compile and execute the code. Fix any errors that occur at either stage. Continue this process until the program runs correctly.
  • Document the code by putting your name, the date, assignment number, and instructor in comments at the top of the Driver.java file.
  • Submit your assignment be either:
    • uploading both files within the CSCI130_A3_yourname folder to Canvas
      OR
    • zipping the entire CSCI130_A3_yourname folder and uploading the zipped file to Canvas

In: Computer Science

KNAPSACK Optimization Problem using Greedy Method Problem 1: Item Weight Value 1 14 20 2 6...

KNAPSACK Optimization Problem using Greedy Method
Problem 1:
Item Weight Value
1 14 20
2 6 16
3 10 8
4 5 10
5 4 12
Allowed weight = 24 Kg

Problem 2:
Item Weight Value
1 6 30
2 8 40
3 15 45
4 22 88
5 25 80
Allowed weight = 60 Kg

Problem 3:
Item Weight Value
1 6 30
2 8 40
3 15 45
4 22 88
5 25 80
Allowed weight = 60 Kg



In: Computer Science

We continue from the two tables in lab 3 part 2, and practice with functions and...

We continue from the two tables in lab 3 part 2, and practice with functions and the GROUP BY statement. The data in each table should be as below

Table Product:

PROD_ID

PROD_NAME

PROD_PRICE

PROD_VENDOR

1101

Table

100

2

1102

Chair

80

3

1103

Armchair

90

2

1104

Nightstand

110

1

1105

Bed

200

3

1106

Dresser

150

3

1107

Daybed

190

2

1108

Ash Table

120

2

1109

Cherry Table

130

2

1110

Table - High

100

2

1111

Office Chair

110

3

Table Vendor:

VEND_ID

VEND_NAME

VEND_ST

1

Green Way Inc

GA

2

Forrest LLC

NC

3

AmeriMart

NC

Please write the SQL script and provide screenshots of results for these below queries. Please include the SQL in text format, and all screenshots in one single document.

  1. Find the average prices by vendors (please include vendor names in the query result)
  2. Find the average prices by states

Help:

I do it the following way, but it gives me an error " NO ROWS SELECTED." Also, I had to  group by V.VEND_NAME, P.PROD_VENDOR, otherwise I'll  get an error message. Please help me figure this out. Same for # 5. Thanks.

select P.PROD_VENDOR, V.VEND_NAME, avg(P.PROD_PRICE) as AVG_PRICE from

PRODUCT P join Vendor V on P.PROD_VENDOR = V.VEND_ID group by V.VEND_NAME, P.PROD_VENDOR;

In: Computer Science

using 8 bits and 2s complement integer arithmetic, show how a processor would calculate 63 -...

using 8 bits and 2s complement integer arithmetic, show how a processor would calculate 63 - 17

In: Computer Science

For this question, you are given a negotiated statement of requirements and asked to produce a...

For this question, you are given a negotiated statement of requirements and asked to produce a structural model.

Here is the negotiated statement of requirements (NSR) for the PickMeNow System (PMNS):

PickMeNow is a new taxi company which has started its operations recently. In order to meet the on-demand transportation needs of its customers, PickMeNow has decided to invest in an IT solution to connect its customers and drivers.

Drivers and customers are required to register with PickMeNow by providing a name, contact number and an email address. PickMeNow assigns an identification number to each registered driver and customer. In addition, each driver is required to provide the details of his bank account (account number and bank name) and vehicle details as described below. Drivers can transfer the amount in his PickMeNow account to his bank account.

PickMeNow provides three types of vehicle to its customers: cars, vans and mini buses. For each vehicle, it is required to capture its licence plate number, brand and model. When a customer makes a booking for a mini bus, he has to make an upfront deposit amount. The deposit will be returned to the customer if the booking is not cancelled by the customer. For vans, there is a booking fee on top of the trip fare. If a customer cancels a booking for a mini bus, the deposit is forfeited if the cancellation is received 3 days before the date of the ride.

When a customer submits a booking to PickMeNow, he needs to specify the date and time, vehicle type, the pick-up point and destination of the trip. PickMeNow would generate a booking id, calculate the fare and broadcast this trip to all available drivers who are free to accept the booking. The customer would then choose a driver from the list of drivers who had accepted the booking. The chosen driver would then proceed to provide the taxi service to the customer.

The data to be kept for each ride includes a reference number, driver and customer details (identification number and name), fare, pick-up point, destination, distance, date, start time and end time of the ride. At the end of each ride, the driver’s account will be credited with the amount of the fare minus any fee due to PickMeNow.

After completing a ride, customers can accumulate points. After completing rides worth a total of $400, the customer will become a Premium customer. Only Premium customers can redeem their points to pay their bill. Points may be used to offset a customer’s bill and if there are insufficient points, the rest of the bill must be paid using a credit card.

Develop a structural model for the system design, by submitting your answers to the following:

(a) Identify the classes, their attributes and any hierarchical relationship(s), omitting the foreign key associations that would be required for the application. Submit the class description as your answer.

(b) Appraise the associations among the classes and hierarchical relationship(s) that would be required for the application. Construct the class-association diagram in UML as your answer. Any derived association should be labelled, but you need not give the derivation.

In: Computer Science