Python:
Create two Binary Tree class methods that can return the maximum value within a Binary Tree and the minimum value within a Binary Tree.
Test the methods in your code
Example syntax to call these methods:
MyTree.Max()
MyTree.Min()
In: Computer Science
A simple way to write the code to convert millileters to ounces in java
In: Computer Science
How to make a flow chart out of this???
To compute the rates you have the following established: 1. Regular service - $6.00 plus first 50 minutes free. Charges for over 50 minutes are $0.20 per minute. 2. Premium service - $15.00 plus: a. For calls made from 6:00am to 6:00pm, the first 75 minutes are free; charges for over 75 minutes are $0.10 per minute. b. For calls made from 6:00pm to 6:00am, the first 100 minutes are free; charges for over 100 minutes are $0.05 per minutes. Task Your task at the moment is to calculate and print out the bill for your customers. Your program should: 1. prompt the user to enter an account number, 2. a service code (type char), a. A service code of r or R means regular service b. A service code of p or P means premium service c. Treat any other character as an error 3. the number of minutes the service was used. Your program should output the account number, type of service, number of minutes the telephone service was used, and the amount due from the user. For the premium service, the customer may be using the service during the day and the night. Therefore, to calculate the bill, you must ask the user to input the number of minutes the service was used during the day and the number of minutes the service was used during the night. Concepts to follow: 1. Assign values to all constant variables that are associated with charges and number of minutes provided in the problem description. 2. The only information the user enters are: account number, type of service, minutes used, and day/night time minutes used based on the plan they have. 3. Remember you are dealing with money therefore should only have 2 decimal places. 4. You must use both a switch statement AND if/else, if/else if’s, or if’s as you see fit. 5. Keep in mind to check for input validation. If validation is incorrect you should have an error message and “kill” your program. 6. Do not use loops
// Cellphone use
#include <iostream>
#include<conio.h>
#include <iomanip>
using namespace std;
int account_number;
float minutes;
char service;
float amount_due;
float day_min;
float night_min;
float regular();
float premium();
int main()
{
cout<< "Please enter your account number: " ;
cin >> account_number;
cout<< "Do you have Regular service or Premium service (r or
p)? ";
cin >> service;
// cout<< service <<endl;;
if (service == 'r' || service == 'R')
regular();
else if (service == 'p' || service == 'P')
premium();
else
{
cout<< "Wrong input, program terminated!" <<
endl;
getch();
return 1;
}
getch();
return 0;
}
float premium()
{
cout<< "How many minutes were used during the day?
";
cin >> day_min;
cout<< "How many minutes were used during the night? ";
cin >>night_min;
if (day_min > 75)
{
amount_due = ((day_min - 75) * .10)+ 15.00;
}
if (night_min > 100)
{
amount_due = ((day_min - 100) * .05)+ 15.00;
}
amount_due = amount_due + 15.00;
cout<< fixed << showpoint <<
setprecision(2);
cout<< "Amount due: $" << amount_due <<
endl;
cout<< "Account number: "<< account_number
<<endl;
cout<< "Service type: "<< service << endl;
cout<< "Minutes used: "<< (day_min+night_min)
<<endl;
return 0;
}
float regular ()
{
cout<< "How many minutes were used? ";
cin >> minutes;
if (minutes <= 50.00)
{
amount_due = 6.00;
cout<< fixed << showpoint <<
setprecision(2);
cout<< "Amount due: $" << amount_due <<
endl;
cout<< "Account number: "<< account_number
<<endl;
cout<< "Service type: "<< service << endl;
cout<< "Minutes used: "<< minutes <<endl;
}
else
{
amount_due = ((minutes -50.00) * 0.20);
cout<< setw(2) << showpoint <<
setprecision(3)<< "Amount due: $"<< amount_due <<
endl;
cout<< "Account number: "<< account_number
<<endl;
cout<< "Service type: "<< service << endl;
cout<< "Minutes used: "<< minutes <<endl;
}
getch();
return 0;
}
In: Computer Science
Lab 7 - 2D Arrays (C++) In main, declare and fill a 2D array with one hundred rows and fifty columns. Iterate through each element and assign it a random value between -72 and 75 inclusive. Have your random number seed be 25. Create functions that do the following: 1. A function called “sum” that returns the sum of all the elements in your 2D Array. 2. A function called “average” that return the average value of the elements in your 2D array. 3. A function called “column_average” that returns the average of a specified column in your 2D array. 4. A function called “row_average” that returns the average of a specified row in your 2D array. 5. A function called “sort_row” that sorts a specified row in your 2D array. 6. A function called "search" that does a linear search on a user specified row and returns the columns index where it was found. If it wasn't found, return -1. Make sure you pass in the value to be search for.. Create a menu system that enables the user to call each of the above functions. For 3 and 4 allow the user to enter the column or row they wish to see the averages of. For 5, allow the user to specify the row to be sorted and ask them if they would like to see the min and max element of that row. The user should be able to enter ‘Y’, ‘y’, ‘N’, or ‘n’. Make sure to validate all user input. If they entered an invalid value, don’t ask them for a valid input and just pass zero to your function. For 6, ask the user for the row and value (space separated) to be searched.
In: Computer Science
Write in Python.
come up with a programming task for which you will write your own program. It should be a purposeful and non-trivial program, bigger than any programming assignment. But it should not be something too ambitious that you may not end up finishing by the deadline. The program must not be something available on the Internet or in a book. The program must satisfy the following five requirements:
Please feel free to contact the instructor if any help is needed at any stage of the project.
Submission:
In: Computer Science
1) Write a denotational semantics for do-while loop
In: Computer Science
Please show full work and give explanation to be upvoted.
11. How does a program determine whether or not to jump based off of a comparison?(In assembly language)
12. Left shift 15 by 3
In: Computer Science
What is the output of the StackQueueMystery algorithm (below) when we have enqueued 1, 2, 5, 6, 3, 7, 4, 10, 8, 9 on q and pushed 8, 6, 9, 7, 10, 5, 4, 3, 2, 1 on stk (in that order) before calling this algorithm. Show your work.
StackQueueMystery:
Input: stk: stack with integers 1-n
Input: q: queue with integers 1-n
Input: n: size and range of stk and q
Pseudocode:
count = 0
while stk and q are not empty:
{
x = x0 = stk.pop()
y = y0 = q.dequeue()
while x != y0 and stk is not empty
x = stk.pop()
while y != x0 and q is not empty
y = q.dequeue()
count = count + 1
}
return count
In: Computer Science
in PYTHON
If varible counter contains an integer, then write an augmented assignment operation to decrement it by 1. A “count-controlled” for loop using the xrange function to average the scores for a class is given below and in the file PartD_average_with_for.py:
# Calculates the average score using a counter-controlled for-loop numberOfScores = input("Enter the number of scores to average: ")
total = 0.0;
for counter in xrange(numberOfScores):
score = input("Enter score #" + str(counter+1) + ": ") total = total + score
if numberOfScores > 0:
print "The average score is", total / numberOfScores
In: Computer Science
Hi, i need to generate into groups the array.For example:
([ 'a', 'b', 'c', 'd' ], 2)=>[ [ 'a', 'b' ], [ 'c', 'd' ] ]
([ { id: 5 }, { id: 10 }, { id: 20 } ], 2)=>. ([ [ { id: 5 }, { id: 10 } ], [ { id: 20 } ] ])
In javascript please
utils={ }
utils.generateGroups = () => { | |
// INPUT arguments | |
// - A 1-dimensional array | |
// - The length of each subgroup that should be created | |
// | |
// RETURN value | |
// - A 2-dimensional array of arrays. Each subarray should be as long as the length argument passed in to the function, except for the final subarray, which can be shorter and contain a "remainder" smaller than that length. | |
// | |
//your code here | |
}; |
In: Computer Science
Design a class that holds the following personal data: name and phone number. Write appropriate accessor and mutator methods. Also, design a program that creates two instances of the class. One instance should hold your information, and the other should hold your friends information. phone numbers should be fake.
In: Computer Science
19. Explain two factor authentication and provide at least two examples of how this authentication method can be implemented.
20. How is ethics different from law? Explain in detail, please!
In: Computer Science
6. Write a program in java which has two arays of size 4 and 5; merge them and sort.
In: Computer Science
Question 14: Find the running time function, T(n), of the program below.
def prob14(L):
if len(L) <= 1:
return 0
output = 0
for x in L:
for y in L:
output += x*y
for x in L:
output += x
left = L[ 0 : len(L)//2 ]
right = L[ len(L)//2 : len(L) ]
return output + prob15(left) + prob15(right)
ANSWER:
T(n) = ...
***Big-O, Omega, Theta complexity of functions, Running time equations of iterative functions & recursive functions, Substitution method & Master theorem
Please answer within these topics.***
In: Computer Science
Compare and Contrast MIPS and ARMS using the 7 ISA dimensions
In: Computer Science