Design, implement and verify a car buzzer that warns car passengers when the door is open or the seatbelt is not used whenever the car key is inserted in the ignition lock, written in VHDL code.
In: Computer Science
#include <stdio.h>
const int DECK_SIZE = 52;
int deck[DECK_SIZE];
int main(void) {
/* Populate the deck */
for(int i = 0; i < DECK_SIZE; i++) {
deck[i] = i + 1;
}
/* Get the cut position as an integer input */
/* Verify that the input is valid */
/* Cut the deck */
/* Print the resulting deck with one element on each line */
return 0;
}
Write a program that "cuts" a deck of 52 playing cards. Given a cut position, the process of cutting the deck refers to taking all cards before the cut position and moving them to the end of the deck. The order of the cards is maintained. For example, if the deck is cut at position 25, the first 25 cards of the deck are moved to become the last 25 cards of the deck. The new first card in the deck is card 26, and the new last card of the deck is card 25.
The deck of cards is represented as a 52-element integer array, with values 1 through 52 representing the different cards. The initial population of the deck is done for you.
Your program should accept a single integer input, which is the cut position. If the input is less than 1 or greater than 52, your program should print "ERROR" and exit. Otherwise, after performing the cut, your program should print out the new deck, with one card value on each line.
Please use C language only. Please make it simple as this is an introductory C programming course
In: Computer Science
A museum's fee policy is that anyone who is either 12 and under or 65 and older receives free admission. Declare a boolean variable named freeAdmissionand set it based on the value in an integer variable age. To receive full credit you should only use one statement. Hint use boolean operators. in Java-Eclipes
In: Computer Science
In Python
A child is required to use a booster seat in a car until the child is 9 years old, unless the child reaches the height of 59 inches before age 9. Which expression can be used to decide if a child requires a car seat or not?
| a. |
if age < 9 or height < 59: |
|
| b. |
if age >= 9 or height >= 59: |
|
| c. |
if age >= 9 and height >= 59: |
|
| d. |
if age <= 9 and height <=59: |
|
| e. |
None of the above |
What conditions have to be true to make the following code display "B"?
if color == 'red':
if style < 3:
print('A')
elif style < 5:
print('B')
else:
print('C')
elif color == 'blue':
print('D')
| a. |
color is 'blue' and style is 3 |
|
| b. |
color is 'red' and style is 6 |
|
| c. |
color is 'red' and style is 5 |
|
| d. |
color is 'red' and style is 4 |
|
| e. |
None of the above |
What conditions have to be true to make the following code display "B"?
if color == 'red':
if style < 3:
print('A')
elif style < 5:
print('B')
else:
print('C')
elif color == 'blue':
print('D')
| a. |
color is 'blue' and style is 3 |
|
| b. |
color is 'red' and style is 6 |
|
| c. |
color is 'red' and style is 5 |
|
| d. |
color is 'red' and style is 4 |
|
| e. |
None of the above |
Which statement is equivalent to the following assignment?
x -= 2 + y
| a. |
x = 2 + y - x |
|
| b. |
x = -(2 + y) |
|
| c. |
x = x - (2 + y) |
|
| d. |
x = x - 2 + y |
|
| e. |
None of the above |
Which of the following data values is best represented with a floating point variable?
| a. |
The speed of a snail. |
|
| b. |
None of the other options |
|
| c. |
The number of children in a classroom. |
|
| d. |
The number of acorns in a tree. |
|
| e. |
The number of pets in a house. |
In: Computer Science
The program runs but the math is not correct ( output for amount )
#include <iostream>
using namespace std;
int main()
{
int hoursParked;
double total;
double Car = 2.50 ;
double Truck = 5.50;
double Bus = 19.00;
double rateC = 1.50;
double rateT = 3.75;
double rateB = 6.75;
char type;
cout << "Please Enter number of hours parked and the type of
car (Type: (C)ar or (T)ruck or (B)us): " << endl;
cin >> type >> hoursParked;
switch (type)
{
case 'C':
case 'c':
{
if (hoursParked <= 2.00)
total = 2 * 1.25;
else
total = (( hoursParked - 2.00 )* rateC)+ Car ;
}
case 'T':
case 't':
{
if (hoursParked <= 2.00)
total = Truck;
else
total = ((hoursParked - 2.00) * rateT) + Truck;
break;
}
case 'B':
case 'b':
{
if (hoursParked <= 2.00)
total = Bus;
else
total = ((hoursParked - 2.00)*rateB) + Bus;
break;
}
}
cout << "Vehicle type: ";
if(type == 'C')
cout << "Car" << endl;
else if(type == 'T')
cout << "Truck" << endl;
else
cout << "Bus" << endl;
cout << "Time:" << hoursParked << endl;
cout << "Amount Due:$" << total <<endl;
return 0;
}
In: Computer Science
In: Computer Science
Using the provided m1_mbox.txt, write a program that reads the data from the file, locates the lines containing sender information (those lines begin with 'From:'), and extracts just the email address of the sender of each message. It should then duplicate the set of email addresses for senders, and write the duplicated list to a file called senders.txt, so that each sender appears in the output file only once. In addition, your program should print to the screen the following stats: total number of email messages in the file, and number of unique senders. Your program should expect the input and output files to be in the same directory and you should hardcode this into your program (that is, do not use command line arguments).
In: Computer Science
State the data cube computation methods. Give example for each method
In: Computer Science
In: Computer Science
In Python
Which initial value of x will make the following piece of code
leave a 9 in the final value of x?
x = ____?
if x < 7:
x = x + 1
x = x + 2
| a. |
11 |
|
| b. |
9 |
|
| c. |
7 |
|
| d. |
None of the above |
Which initial value of x will make the following piece of code
leave a 20 in the final value of x?
x = ____?
if x * 2 <= 34:
x = 0
else:
x = x + 1
x = x + 1
| a. |
17 |
|
| b. |
18 |
|
| c. |
19 |
|
| d. |
20 |
|
| e. |
None of the above |
What is a common word for the textual representation of a program?
| a. |
code |
|
| b. |
prompt |
|
| c. |
interpreter |
|
| d. |
expression |
|
| e. |
None of the above |
Which statement reads a user-entered string into variable user_name?
| a. |
input = user_name() |
|
| b. |
user_name = input() |
|
| c. |
input() => user_name |
|
| d. |
user_name = "input()" |
|
| e. |
None of the above |
What is the output?
count = 0
while count < 3:
print('loop')
count = count + 1
print('final value of count:', count)
| a. |
Prints 'loop' once, then 'final value of count: 1' |
|
| b. |
Prints 'loop' three times, then 'final value of count: 3' |
|
| c. |
Prints 'loop' three times, then 'final value of count: 4' |
|
| d. |
Prints 'loop' forever (infinite loop) |
|
| e. |
None of the above |
In: Computer Science
Please
Why do we need a dynamic stack? How to implement a dynamic array stack?(JAVA)
In: Computer Science
In Python
Dividing by zero is an example of which type of error?
| a. |
runtime |
b. |
syntax |
c. |
logic |
d. |
None of the previous |
In the statement:age = input('Enter your age: '), the string 'Enter your age: ' is called a(n) _____.
| a. |
prompt |
|
| b. |
prefix |
|
| c. |
variable |
|
| d. |
assignment |
|
| e. |
None of the above |
Fill in the blank so that the loop displays all odd numbers from 1 to 100.
i = 1
while i <= 100:
print(i)
i = _____
| a. |
1 |
|
| b. |
i + 1 |
|
| c. |
2 |
|
| d. |
i + 2 |
|
| e. |
None of the above |
How many times does the following loop iterate?
i = 5
while i < 10:
print(i)
i = i + 1
| a. |
0 |
|
| b. |
4 |
|
| c. |
5 |
|
| d. |
6 |
|
| e. |
None of the above |
In: Computer Science
Using the data structure concept of topological ordering,demonstrate using pseudocode how you can implement an operation to schedule picking during a delivery process in a warehouse.
In: Computer Science
Design a class named Person and its two subclasses named Student and Employee. Make Faculty and Staff subclasses of Employee. A person has a name, address, phone number, and e-mail address. A student has a class status (freshman, sophomore, junior, or senior). Define the status as a constant. An employee has an office, salary, and date hired. A faculty member has office hours and a rank. A staff member has a title. Override the toString method in each class to display the class name and the person’s name.
Write a test program that creates objects of Person, Student, Employee, Faculty, and Staff, and invoke their toString() methods.
In: Computer Science
Consider the following description of an enterprise.
An auction Web site has items for sale that are provided by sellers. Each item has an opening price, a description, and ending time. Customers submit bids. The highest earliest bid submitted before the ending time is the winning bid and the item is sold to the bidder. Each seller must pay 5% of the winning bid. The auction company wants to be able to analyze the sales behavior of its customers and sellers and so must keep track of all bids and sales.
In: Computer Science