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
Is there any idea that what is the R formula for next ten days of weather if you can advice
In: Computer Science
(To be written in Java code)
A personal phone directory contains room for first names and phone numbers for 30 people. Assign names and phone numbers for the first 10 people. Prompt the user for a name, and if the name is found in the list, display the corresponding phone number. If the name is not found in the list, prompt the user for a phone number, and add the new name and phone number to the list.
Continue to prompt the user for names until the user enters quit. After the arrays are full (containing 30 names), do not allow the user to add new entries.
Use the following names and phone numbers:
Name | Phone # |
---|---|
Gina | (847) 341-0912 |
Marcia | (847) 341-2392 |
Rita | (847) 354-0654 |
Jennifer | (414) 234-0912 |
Fred | (414) 435-6567 |
Neil | (608) 123-0904 |
Judy | (608) 435-0434 |
Arlene | (608) 123-0312 |
LaWanda | (920) 787-9813 |
Deepak | (930) 412-0991 |
This code was provided to start with:
import java.util.*;
class PhoneNumbers
{
public static void main (String[] args)
{
// write code here
}
}
In: Computer Science
The bits transmitted by four stations A, B, C and D are multiplexed using Code Division Multiplexing (CDMA). Assume A transmits a 1 bit, B transmits a 0 bit, C transmits a 1 bit, and D is silent. Assume the following are the chip sequences of the four stations, answer below questions: SA = (-1 -1 -1 +1 +1 -1 +1 +1); SC = (-1 -1 +1 -1 +1 +1 +1 -1) SB = (-1 +1 -1 +1 +1 +1 -1 -1); SD = (-1 +1 -1 -1 -1 -1 +1 -1)
i) What is the transmitted sequence?
ii) Show how the receiver determines station B’s transmission.
In: Computer Science
In.java
In this program write a method called upDown that takes three integers as arguments and returns one of these 3 strings:
In the main method do the following:
read three integers from the user and call upDown for those integers, save the result in a variable, res1, and then print it.
---------- Sample run 1: Enter three integers separated by spaces: 2 0 9 These numbers are in order: none Enter three integers separated by spaces: 17 90 567 These numbers are in order: increasing different ---------- Sample run 2: Enter three integers separated by spaces: 90 9 1 These numbers are in order: decreasing Enter three integers separated by spaces: 7 3 1 These numbers are in order: decreasing same ---------- Sample run 3: Enter three integers separated by spaces: 3 3 4 These numbers are in order: none Enter three integers separated by spaces: 8 1 16 These numbers are in order: none same
In: Computer Science