Questions
Get values for min and max using assignment statements and the input function. Print min and...

  1. Get values for min and max using assignment statements and the input function.
    Print min and max.
    Run the script.
    fix any errors you find.
  2. Remove the print statements you wrote above.
    Print the labels "Kelvin" and "Fahrenheit".
    Print a line of dashes under the labels.
    Run the script.
    fix any errors you find.
  3. Write a for loop that will give the loop variable kelvin values between min and max.
    Inside the code block print the value of kelvin
    Run the script.
    fix any errors you find.
  4. Remove the print statement inside the for a loop.
    Write an assignment statement that calculates the value of the equivalent Fahrenheit temperature.
    Print the Fahrenheit and Kelvin temperatures.
    Run the script.
    fix any errors you find.
  5. Use escape characters to align the Fahrenheit values with their label.
    Run the script.
    fix any errors you find.

In: Computer Science

The main function creates 5 pixels with random red, green, and blue values. Complete the id_color...

The main function creates 5 pixels with random red, green, and blue values. Complete the id_color function to return “red” if the red value is greater than the green and blue, “green” if the green value is greater than the red and blue, and “blue” if the blue value is greater than the red and green. If there is no clear maximum value (for example, if the red and green values are the same) return None. Do not change the main function.

import image
import random

def id_color(p):
'''Returns the dominant color of pixel p'''
pass
#Your code here to determine the dominant color and return a string identifying it
#Hint: get the red, green & blue values and use an if statement to determine which has the highest value

def main():
'''Controls the program'''
for i in range(5): #Loop 5 times
r = random.randrange(0, 256)
g = random.randrange(0, 256)
b = random.randrange(0, 256)
print(r, g, b) #Show the pixel red, green & blue values
new_pixel = image.Pixel(r, g, b)
print(id_color(new_pixel))

main() #Run the program

In: Computer Science

First, launch NetBeans and close any previous projects that may be open (at the top menu...

First, launch NetBeans and close any previous projects that may be open (at the top menu go to File ==> Close All Projects).

Then create a new Java application called "BackwardsStrings" (without the quotation marks) that:

  1. Prompts the user at the command line for one 3-character string.
  2. Then (after the user inputs that first 3-character string) prompts the user for another 3-character string.
  3. Then prints out the two input strings with a space between them.
  4. Finally prints on a separate line the two input strings 'in reverse' (see example below) with a space between them.

So, for example, if the first string is 'usr' and the second string is 'bin', your program would output something like the following:

The two strings you entered are: usr bin.
The two strings in reverse are: nib rsu.

Note that the reversed SECOND string comes FIRST when printing the strings in reverse.

This program must be completed without using loops and without using StringBuilder.

See Horstmann pp. 62-63 for some ideas. Make sure your program includes the command line prompts for the user and that it formats the output appropriately.

Be sure both input strings are three characters in length. If this data validation isn't passed, output "Invalid string length for one or both inputs." and do not proceed with further processing of the strings.

In: Computer Science

Write a program 'Rectangle-Area.c' that inputs the length and width of a rectangle and outputs its...

Write a program 'Rectangle-Area.c' that inputs the length and width of a rectangle and outputs its area. The program consists of two functions: the main function and a function that computes and returns the area of a rectangle. The output of the program should be in the main program, not in the function.

     Sample Input: 5 8   Sample Output: The area of a 5 by 8 rectangle is 40.

In: Computer Science

What is a network access point? I am trying to draw a network model for the...

What is a network access point?

I am trying to draw a network model for the company "Slack". What would be considered an access point to a big company like that. I have an example that says small businesses use LAN

In: Computer Science

In bash Write a script which receives a list of parameters. If no parameters are received,...

In bash

Write a script which receives a list of parameters. If no parameters are received, output an error message. Otherwise, iterate through the list and, using a case statement, test each item in the list to see if it starts with a capital letter, lower case letter, digit or other. Count each type and output at the end the total for each category (capital, lower case, digit, other).

In: Computer Science

I need an infix to postfix function that accounts for all (, ), {, }, [,...

I need an infix to postfix function that accounts for all (, ), {, }, [, ].. For example.

8-{{(1-[0+4]+8)}}

In c++ please.

In: Computer Science

The Gas-N-Clean Service Station sells gasoline and has a car wash. Fees for the car wash...

The Gas-N-Clean Service Station sells gasoline and has a car wash. Fees for the car wash are $1.25 with a gasoline purchase of $10.00 or more and $3.00 otherwise. Three kinds of gasoline are available: regular at $2.89, plus at $3.09, and super at $3.39 per gallon.


User Request:

Write a program that prints a statement for a customer.


Analysis:

Input consists of number of gallons purchased (R, P, S, or N for no purchase), and car wash desired (Y or N). Gasoline price should be program defined constant. Sample output for these data is


Enter number of gallons and press <Enter> 9.7

Enter gas type (R, P, S, or N) and press <Enter> R

Enter Y or N for car wash and press <Enter> Y


**************************************

* *

* *

* Gas-N-Clean Service Station *

* *

* March 2, 2004 *

* *

**************************************

Amount Gasoline purchases 9.7 Gallons

Price pre gallons $ 2.89

Total gasoline cost $ 28.03

Car wash cost $ 1.25

Total due $ 29.28


Thank you for stopping

Please come again

Remember to buckle up and drive safely

program used is c++

In: Computer Science

First, launch NetBeans and close any previous projects that may be open (at the top menu...

First, launch NetBeans and close any previous projects that may be open (at the top menu go to File ==> Close All Projects). Then create a new Java application called "PasswordChecker" (without the quotation marks) that gets a String of a single word from the user at the command line and checks whether the String, called inputPassword, conforms to the following password policy. The password must: Be exactly three characters in length Include at least one uppercase character Include at least one digit If the password conforms to the policy, output "The provided password is valid." Otherwise, output "The provided password is invalid because it must be three characters in length and include at least one digit and at least one uppercase character. Please try again." Some other points to remember... Do not use a loop in this program.

The Character class offers various methods to assist us in finding a digit or cased letter. Remember to press "." to locate these methods and to leverage the online resources shown in our course thus far." For this PA, do not use pattern matching (aka "regular expressions").

In: Computer Science

Inheritance – Address, PersonAddress, BusinessAddress Classes Assignment Download the Lab6.zip starter file. Use 7zip to unzip...

Inheritance – Address, PersonAddress, BusinessAddress Classes

Assignment

Download the Lab6.zip starter file. Use 7zip to unzip the file using ‘Extract Here’. Open the project folder in IntelliJ.

Examine the Main and Address classes. You are going to add two classes derived from Address: BusinessAddress and PersonAddress.

Create BusinessAddress class

  1. Select package edu.cscc and create a new Java class called BusinessAddress  
  2. Make the class extend the Address class
  3. Add two private String fields businessName and address2
  4. Generate constructor and all getters and setters
  5. Add a printLabel() method

The printLabel method should print (using System.out.println()) // Here is the 1st place I'm getting stuck ?? All I did was create the BusinessAddress class. I appreciate your assistance

First line – the businessName field

Second line – the address2 field if it is not null or empty

Third line – the StreetAddress field if it is not null or empty

Fourth line – city field followed by a comma and space, the state field followed by two spaces, and the zip field

Create PersonAddress class

  1. Select package edu.cscc and create a new Java class called PersonAddress
  2. Make the class extend the Address class
  3. Add a private String field personName
  4. Generate constructor and all getters and setters
  5. Add a printLabel() method

The printLabel method should print (using System.out.println())

First line – the personName field

Second line – the StreetAddress field

Third line – city field followed by a comma and space, the state field followed by two spaces, and the zip field

Modify Main class

Add the following three BusinessAddress objects to the list.

BusinessName

Address2

StreetAddress

City

State

Zip

Columbus State

Eibling 302B

550 East Spring St.

Columbus

OH

43215

AEP

P.O. Box 2075

null

Columbus

OH

43201

Bill’s Coffee

null

2079 N. Main St.

Columbus

OH

43227

Add the following three PersonAddress objects to the list.

PersonName

StreetAddress

City

State

Zip

Saul Goodman

1200 N. Fourth St.

Worthington

OH

43217

Mike Ehrmentraut

207 Main St.

Reynoldsburg

OH

43211

Gustavo Fring

2091 Elm St.

Pickerington

OH

43191

Example Output

Columbus State

Eibling 302B

550 East Spring St.

Columbus, OH 43215

====================

AEP

P.O. Box 2075

Columbus, OH 43201

====================

Bill's Coffee

2079 N. Main St.

Columbus, OH 43227

====================

Saul Goodman

1200 N. Fourth St.

Worthington, OH 43217

====================

Mike Ehrmentraut

207 Main St.

Reynoldsburg, OH 43211

====================

Gustavo Fring

2091 Elm St.

Pickerington, OH 43191

====================

public class Main {

    public static void main(String[] args) {
       Address[] addressList = new Address[6];

       // TODO Add 3 person addresses to list

        // TODO Add 3 business address to list

       for (Address address : addressList) {
           address.printLabel();
            System.out.println("====================");
        }
    }
}
public abstract class Address {
    private String streetAddress;
    private String city;
    private String state;
    private String zip;

    public Address(String streetAddress, String city, String state, String zip) {
        this.streetAddress = streetAddress;
        this.city = city;
        this.state = state;
        this.zip = zip;
    }

    public String getStreetAddress() {
        return streetAddress;
    }

    public void setStreetAddress(String streetAddress) {
        this.streetAddress = streetAddress;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    public String getZip() {
        return zip;
    }

    public void setZip(String zip) {
        this.zip = zip;
    }

    public String toString() {
        return streetAddress + "\n" +
                city + ", " + state + "  " + zip + "\n";
    }

    public abstract void printLabel();
}

public class BusinessAddress extends Address {

    private String businessName;
    private String address2;

    public BusinessAddress(String streetAddress, String city, String state, String zip, String businessName, String address2) {
        super(streetAddress, city, state, zip);
        this.businessName = businessName;
        this.address2 = address2;
    }

    public String getBusinessName() {
        return businessName;
    }

    public void setBusinessName(String businessName) {
        this.businessName = businessName;
    }

    public String getAddress2() {
        return address2;
    }

    public void setAddress2(String address2) {
        this.address2 = address2;
    }

    public void printLabel() {

    }
}

In: Computer Science

Write a C program to run on unix to read a text file and print it...

Write a C program to run on unix to read a text file and print it to the display. It should count of the number of words in the file, find the number of occurrences of a substring, and take all the words in the string and sort them (ASCII order). You must use getopt to parse the command line. There is no user input while this program is running.

Usage: mywords [-cs] [-f substring] filename

• The -c flag means to count the number of words in the file. A word would be a series of characters separated by spaces or punctuation. A word could include a hyphen or a single apostrophe.

• The -s option means to print the words in the file sorted by ASCII order.

• The -f option will find the number of occurrences of the given substring.

• You may have any number of the flags included or none of them.

• The order they should be run would be: -s first, -c second, and -f third.

--------------------------------------------------------------------------------

Format of parsing the command line (main method established), rest of functionality needed as explained above:

int value = 0;

int main(int argc, char **argv) {
    extern char *optarg;
    extern int optind;
    int c, err = 0;
    int cflag = 0, sflag = 0, fflag = 0;
    char *substring;

    // usage 
    static char usage[] = "usage: mywords [-cs] [-f substring] filename";  

    while ((c = getopt(argc, argv, "csf:")) != -1)
        switch (c) {
            case 'c':
                cflag = 1;
                break;

            case 's':
                sflag = 1;
                break;

            case 'f':
                fflag = 1;
                substring = optarg;
                break;

            case '?':
                err = 1;
                break;
        }

    if (fflag == 1) {
        printf("%c ", substring);
    }
}

In: Computer Science

Write a C++ program that makes a 10x10 array and picks random letters and displays in...

Write a C++ program that makes a 10x10 array and picks random letters and displays in different positions

In: Computer Science

Modify the MergeSort program given to support searching subarrays. Program is listed below in Java. public...

Modify the MergeSort program given to support searching subarrays.

Program is listed below in Java.

public class Merge

{

public static void sort(Comparable[] a)

}

Comparable[] aux = new Comparable[a.length];

sort(a, aux, 0, a.length);

}

private static void sort(Comparable[] a, Comparable[] aux, int lo, int hi)

{ //Sort a[lo, hi)

if (hi - lo <= 1) return;

int mid = lo (hi + lo) / 2;

sort( a, aux, lo, mid);

sort(a, aux, mid, hi);

int i = lo, j = mid;

for (int k = lo; k < hi; k++)

if (i == mid) aux[k] = a[j++];

else if (j == hi) aux[k] = a[i++];

else if (a[j].compareTo(a[i]) < 0) aux[k] = a[j++];

else aux[k] = a[i++];

for (int k = lo; k < hi; k++)

a[k] = aux[k];

}

public static void main(String[] args)

{ }

}

Note: The user would give an unsorted list of words as command-line arguments along with the starting and ending index of the subarray that should be sorted. The program should print out a list where the strings between the given indexes are sorted alphabetically.

  • Sample runs would be as follows.

>java MergeSort 2 4 toy apply sand bay cat dog fish

toy apply bay cat sand dog fish

>java MergeSort 0 3 was had him and you his the but

and had him was you his the but

In: Computer Science

Instructions: A movie theater only keeps a percentage of the revenue earned from ticket sales. The...

Instructions: A movie theater only keeps a percentage of the revenue earned from ticket sales. The remainder goes to the movie distributor. Write a program that calculates a theater’s gross and net box office profit for a night. The program should ask for the name of the movie, and how many adults and child tickets were sold. The price of an adult ticket is $10.00 ad a child ticket is $6.00.) It should display a report similar to


Movie Name: “Wheels of Fury”

Adult Tickets Sold: 382

Child Tickets Sold: 127

Gross Box Office Profit: $4582.00

Net Box Office Profit: $916.40

Amount Paid to Distributor: $3665.60


program used is c++

In: Computer Science

Typed please.How can we implement efficient search operations? In this area, we will discuss various algorithms,...

Typed please.How can we implement efficient search operations? In this area, we will discuss various algorithms, including sequential search, sorted search, and binary search. The characteristics of these algorithms will be analyzed, such as the running times and the type of lists they can be used with.

In: Computer Science