Questions
Write a program in python to calculate the amount each person must pay toward the bill...

Write a program in python to calculate the amount each person must pay toward the bill and toward the tip, for a group of friends who are eating out together. Since you are all friends, it is okay to split the costs evenly.

Your program should take as input:

  1. The restaurant bill (without tax or tip) as a floating point number
  2. The sales tax rate as a floating point number (for example: an 8% tax rate would be 0.08)
  3. The level of service as an integer between 0 and 10
    0 is terrible (0% tip), 5 is average (15% tip), and 10 is excellent (30% tip)
  4. The number of friends to split the check among

Your program should output:

  1. The amount each friend should pay toward the bill (with tax)
  2. The amount each friend should leave in tip
    tip should be calculated on the pre-tax restaurant bill
  3. The total amount each diner should pay, including restaurant bill, sales tax, and tip
  4. The overall total, which includes the restaurant bill, the sales tax, and the tip

For example, with the following inputs:

Restaurant bill (without tax or tip): $35
Sales tax rate: 0.08
Level of service: 7
Number of friends: 3

the output should be:

Bill per person with tax: $12.6
Tip per person: $2.4499999999999997
Total per person: $15.049999999999999
Total bill including tax and tip: $45.15 

Note that because floating point values often incur rounding errors, the output might not be completely accurate. This will not affect the grading. However, please make your input and output look like the example above, so that the automated system can evaluate your results.

Things to think about when you’re writing these programs:

  1. Follow the recipe: collect all your input first; then calculate the required results; then output the results.
  2. Spend some time choosing your variable names carefully. Names should be descriptive.
  3. Take advantage of variables to name values whose purpose may not be obvious.
  4. Take advantage of variables by breaking any complex expressions down into a set of simpler expressions and storing the intermediate results in variables

In: Computer Science

This is an intro to Java Question. My current solution is giving me bad outputs. Please...

This is an intro to Java Question. My current solution is giving me bad outputs. Please show me your way of solving this.

Problem 4: Min/Max Search by Value Develop a program that, given a sequence S of integers as input, produces as two output values, the first is the minimum value that appears in the sequence and the second is the maximum value that appears in the sequence.

Facts

● Scanner has a method that returns a boolean indicating whether a next integer exists in its input stream ( hasNextInt() )

● Scanner objects can be initialized to to scan String data as input.

Input

The input will begin with a single line containing T , the number of test cases to follow. The remaining lines contain the T sequences, one line per sequence. Each of these lines contains the values in the sequence. Each such value is separated from the next by at least one space.

Output For each sequence given as input, there should be four lines of output. The first line echos the given sequence. The second line indicates the minimum value that occurs. The third line indicates the maximum value that occurs. The fourth line is blank.

Sample Input

3

3 6 -1 4 6 5 3

0 0 0 0 -4 45 2 0 3 5 11 -7 854 25 3 -7 4 -3

Sample Output 3 6 -1 4 6 5 3

-1

6

0 0 0 0

0

0

-4 45 2 0 3 5 11 -7 854 25 3 -7 4 -3

-7

854

So Far This is what I have:

import java.util.Scanner;

public class MinMaxSearchByValue {

   public static void main(String [] args) {

       Scanner input = new Scanner(System.in);

       int cases = input.nextInt();

       input.nextLine();

       for (int i = 0; i < cases; i++) {

           String givenListOfNums = input.nextLine();

           Scanner stringScanner = new Scanner (givenListOfNums);

           int min = stringScanner.nextint();

           int max = min;

           while (stringScanner.hasNextInt()) {


               int nextValue = stringScanner.nextInt();

               if(nextValue < min) {

                   min = nextValue;}

                   else if (nextValue > max) {
                      
                       max = nextValue;
                   }
           }
       }

System.out.printf("%s%n%d%n%d%n%n", givenListOfNums, min, max);

   }


}

In: Computer Science

What is the output of the following code snippet? (If there is some kind of syntax...

What is the output of the following code snippet? (If there is some kind of syntax error indicate this by marking "error" in your answer choice)

1.

       int laps = 8;

       if (laps++ > --laps)

              laps += 2;

       else if (--laps > (laps - 1))

              laps += 4;

       else if (++laps)

              laps -= 3;

       cout << laps << endl;

2.

What is the output of the following code snippet?

  1.     int j = 47;
  2.     int i = 8;
  3.     j = (j / 3);
  4.     if (j / 2 > i && --i > (j /= 3))
  5.         j += i;
  6.     else
  7.     cout << j << endl;

3.

integer i = 67;
    double d = i - 1;
    i = d;
    character c = i;

    if i > 65
        cout << "The character is: " << c << " in the alphabet" << endl;
    else i <= 65
        cout << "The character is before the alphabet" << endl;

The character is: B in the alphabet

The character is: C in the alphabet

The character is: c in the alphabet

The character is before the alphabet

Error: the code will not compile

4.

What is the output of the following? (if there is a  syntax or runtime error enter “error” for your answer)
 
               int know = 4;
               short test = 5;
               long large = 28;
               
               if (large / 5 < test && ++test > know && ++test < large)
               {
                              test += know;
               }
               else if (--test == know++)
               {
                              test -= know;
               }
               large -= test;
               cout << large << endl;

5.

What is the output of the following code snippet? (If there is some kind of syntax error indicate this by marking "error" in your answer choice)

       //Note that there are no endl's until the end of the problem

       short k = 5;

       float red = 7.7f;

       if (++k < --red)

              cout << k;

       if (k < --red)

              cout << 4;

       if (++red > k--)

              cout << 2;

       cout << k << endl;

In: Computer Science

I have defined the class. Rectangle in Python. How do I define a class Canvas with...

I have defined the class. Rectangle in Python. How do I define a class Canvas with the following description:

Class Canvas represents a collection of Rectangles. It has 8 methods. In addition, to the constructor
(i.e. __init__ method) and two methods that override python's object methods (and make your class
user friendly as suggested by the test cases), your class should contain 5 more methods:
add_one_rectangle, count_same_color, total_perimeter, min_enclosing_rectangle, and common_point.

In: Computer Science

In programming, we are always assigning one variable to another. With the use of primitive data...

In programming, we are always assigning one variable to another. With the use of primitive data types that is not a problem. With classes, the program needs to know how to do the assignment. Explain the concepts of deep copy and member wise assignment.

No duplicate answers please. C++ language

In: Computer Science

Computer Networks – Basic Connections a. Terminal/microcomputer-to-mainframe computer connections b. Microcomputer-to-local area network connections c. Microcomputer-to-Internet...

Computer Networks – Basic Connections
a. Terminal/microcomputer-to-mainframe computer connections
b. Microcomputer-to-local area network connections
c. Microcomputer-to-Internet connections
d. Local area network-to-local area network connections
e. Personal area network-to-workstation connections
f. Local area network-to-metropolitan area network connections
g. Local area network-to-wide area network connections
h. Wide area network-to-wide area network connections
i. IOT sensor-to-local area network connections
j. Satellite and microwave connections
k. Wireless telephone connections

List which of the eleven network connections listed above most likely involve a connection to the Internet

In: Computer Science

Discuss the main characteristics (at least 2-3) of the database approach and how it differs from...

Discuss the main characteristics (at least 2-3) of the database approach and how it differs from traditional file systems. (5 pts) Give examples of systems in which it may make sense to use traditional file processing instead of a database approach. (these examples may come from your day-to-day use of technology)

In: Computer Science

i. Use command ifconfig to find out the IP address of Metasplotiable and record it as...

i. Use command ifconfig to find out the IP address of Metasplotiable and record it as your target_IP.

ii. Open a terminal on Kali and try to login to Metasploitable using the command: ssh root@[target_IP]. Can you log in to the System without providing the password?

iii. Use command nmap to scan all TCP ports on our target machine.

iv. Exploitation: a. Open a terminal on Kali and create a new key pair using ssh-keygen. b. Check if you can mount the target system. c. Mount your target system (Metasploitable) to the NFS. d. Copy the newly generated public key into the target system. e. Dismount the target system.

v. Try to login to the target system without password again.

vi. After login to the target system, do the commands below: whoami hostname date echo “Your name”

1

In: Computer Science

C++ Using what you know about how to take inputs and make outputs to the console,...

C++
Using what you know about how to take inputs and make outputs to the console, create a check printing application. Your application will read in from the user an employee's name and salary, and print out a Console Check similar to the following.

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

> | $1,000,000 | >

> >

> ___Pay to the Order of___ Johnny PayCheck >

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

In: Computer Science

Write a factorial C++ program where n=10,000,000

Write a factorial C++ program where n=10,000,000

In: Computer Science

Write a class file called lastname_digits.java. In it, write a method to compute and return the...

Write a class file called lastname_digits.java. In it, write a method to compute and return the total instances where the sum of digits of the array equals to the target.

Write a demo file called lastname_digits_demo.java. Create an array of random 10 integers between 301 and 999. Also create an integer variable called target that is equal to a value between 5 and 10. Print the answer within this file.

Example:

If five of the 20 integers are equal to 512, 607, 620, 767, 791 and the target is 8. Sum of the four integers is equal to 5+1+2 = 8, 13, 8, 20, 17. Then the total instances where the sum of digits of the array equals to the target is equal to 2.

In: Computer Science

Part One: Write a program to draw a repetitive pattern or outline of a shape using...

Part One: Write a program to draw a repetitive pattern or outline of a shape using for loops and Turtle Graphics. Use the following guidelines to write your program.

  1. Decide on a repetitive pattern or the outline of a shape, such as a house, to draw.
  2. Give your artwork a name. Print the name to the output.
  3. Using for loops and the Turtle Module, draw the outline of a shape or a repetitive pattern.
  4. At least one for loop that repeats three or more times must be used.
  5. Use at least one color apart from black.
  6. Write the pseudocode for this program. Be sure to include any needed input, calculations, and output.

Insert your pseudocode here:

Part Two: Code the program. Use the following guidelines to code your program.

  1. To code the program, use the Python IDLE.
  2. Using comments, type a heading that includes your name, today’s date, and a short description of the program.
  3. Follow the Python style conventions regarding indentation and the use of white space to improve readability.
  4. Use meaningful variable names.

In: Computer Science

Write a “C” program(Linux) that creates a pipe and forks a child process. The parent then...

Write a “C” program(Linux) that creates a pipe and forks a child process. The parent then sends the following message on his side of the pipe “I am your daddy! and my name is <pid-of the-parent-process>\n”, the child receives this message and prints it to its stdout verbatim. The parent then blocks reading on the pipe from the child. The child writes back to its parent through its side ofthe pipe stating “Daddy, my name is <pid-of-the-child>”. The parent then writes the message received from the child to its stdout. Make sure the parent waits on the child exit as to not creating orphans or zombies. Include Makefile.

In: Computer Science

1 of 10 When declaring a jagged array, all dimensions must have the same type. True...

1 of 10

When declaring a jagged array, all dimensions must have the same type.

True
False

Question

2 of 10

What is the maximum number of dimensions you can declare for an array in C#?

3
10
5
There is no maximum.

Question

3 of 10

When you declare a two-dimensional array, you place two numbers within square brackets. What does the first number represent?

Class
Index
Column
Row

Question

4 of 10

When declaring a multidimensional array, all dimensions must have the same type.

True
False

Question

5 of 10

Given the code below, the variables "student1" and "student2" refer to the same memory location.

string student1 = "Student";
string student2 = "Student";

True
False

Question

6 of 10

The code below declares a jagged array.

int[][] jaggedArray = new int[2][];

jaggedArray[0] = new int[20];

jaggedArray[1] = new int[10];

int[0,10] = 95;
int[0][10] = 95;
int[1,11] = 95;
int[1][11] = 95;

Question

7 of 10

Given the code below, what is the output?

string student = " Student";

Console.WriteLine(student.Length)

7
Run-time exception
Compile-time exception
8

Question

8 of 10

Given the code below, what is the output?

string student1 = "Student";

string student2 = "Student";

if(student1 == student2)

{

    Console.WriteLine("True");

}

else

{

    Console.WriteLine("False");

}

True
False

Question

9 of 10

Select the output for the statement below.

int[,] examArray = new int[30, 6];
Console.WriteLine(examArray.GetLength(2));

A compilation error generates.
A run-time error generates.
6
30

Question

10 of 10

You can use multidimensional arrays to store a different number of columns for certain rows.

True
False

In: Computer Science

Given the tables: SKU_DATA (SKU, SKU_Description, Department, Buyer) WAREHOUSE (WarehouseID, WarehouseCity, WarehouseState, Manager, Squarefeet) INVENTORY (WarehouseID,...

  1. Given the tables: SKU_DATA (SKU, SKU_Description, Department, Buyer)

WAREHOUSE (WarehouseID, WarehouseCity, WarehouseState, Manager, Squarefeet)

INVENTORY (WarehouseID, SKU, SKU_Description, QuantityOnHand, QuantityOnOrder)

  1. Write an SQL statement to display SKU and SKU_Description.
  2. Write an SQL statement to display the SKU, SKU_Description, and WarehouseID for products having QuantityOnHand greater than 0. Sort the results in descending order by WarehouseID and ascending order by SKU.
  3. Write an SQL statement to display the SKU, SKU_Description, WarehouseID, WarehouseCity, and WarehouseState for all items stored in the Atlanta, Bangor, or Chicago warehouse
  4. Write an SQL statement to show the SKU, SKU_Description, WarehouseID for all items stored in a warehouse managed by ‘Lucille Smith’. Use a subquery
  5. Write an SQL statement to show the WarehouseID and average QuantityOnHand of all items stored in a warehouse managed by ‘Lucille Smith’.

All for MYSQL Database

In: Computer Science