Questions
C++ exercise: The statements in the file main.cpp are in incorrect order. using namespace std; #include...

C++ exercise:

The statements in the file main.cpp are in incorrect order.

using namespace std;

#include <iostream>


int main()
{
string shape;
double height;
#include <string>
  
cout << "Enter the shape type: (rectangle, circle, cylinder) ";
cin >> shape;
cout << endl;
  
if (shape == "rectangle")
{
cout << "Area of the circle = "
<< PI * pow(radius, 2.0) << endl;
  
cout << "Circumference of the circle: "
<< 2 * PI * radius << endl;
  
cout << "Enter the height of the cylinder: ";
cin >> height;
cout << endl;
  
cout << "Enter the width of the rectangle: ";
cin >> width;
cout << endl;
  
cout << "Perimeter of the rectangle = "
<< 2 * (length + width) << endl;
double width;
}
  
cout << "Surface area of the cylinder: "
<< 2 * PI * radius * height + 2 * PI * pow(radius, 2.0)
<< endl;
}
else if (shape == "circle")
{
cout << "Enter the radius of the circle: ";
cin >> radius;
cout << endl;
  
cout << "Volume of the cylinder = "
<< PI * pow(radius, 2.0)* height << endl;
double length;
}
return 0;

else if (shape == "cylinder")
{
double radius;
  
cout << "Enter the length of the rectangle: ";
cin >> length;
cout << endl;
  
#include <iomanip>
  
cout << "Enter the radius of the base of the cylinder: ";
cin >> radius;
cout << endl;
  
const double PI = 3.1416;
cout << "Area of the rectangle = "
<< length * width << endl;
else
cout << "The program does not handle " << shape << endl;
cout << fixed << showpoint << setprecision(2);
#include <cmath>
}

Rearrange the statements so that they prompt the user to input:

  • The shape type (rectangle, circle, or cylinder)
  • The appropriate dimension of the shape.

Note: For grading purposes place the cylinder height statement before the radius statement.

The program then outputs the following information about the shape:

  • For a rectangle, it outputs the area and perimeter
  • For a circle, it outputs the area and circumference
  • For a cylinder, it outputs the volume and surface area.

Use 3.1416 as the constant value for any calculations that may need \piπ.

After rearranging the statements, your program should be properly indented.

In: Computer Science

All Code should be written in C: 1. Write a C program which prompts the user...

All Code should be written in C:

1. Write a C program which prompts the user to enter two integer values. Your program should then print out all numbers between 1 and 1000 that are divisible by both of those numbers.

2. Modify your program from question 1 such that the first 1000 numbers that are divisible by both numbers are printed out, instead of numbers up to 1000.

3. Using dynamic memory, allocate memory for an array of 100 floating point numbers. Fill this array with random numbers between 0 and 1, and print them to the screen. HINT: Use RAND_MAX, which represents the largest possible value returned by the rand() function.

4. Modify question 3 such that the program writes the values to a file called "floats.txt" in text format, one per line, instead of to the screen

In: Computer Science

All Code should be written in C: 1. A perfect number is defined as a number...

All Code should be written in C:
1. A perfect number is defined as a number whose proper divisors (factors not including the number itself) add up to the same number. For example, 28 is a perfect number because its perfect divisors are 1, 2, 4, 7, 14, which add up to 28. Write a C function called is_perfect that takes a since integer as input, and returns 1 if the number is perfect, or 0 otherwise.

2. Using the function you wrote in Q1, write a C program to print out all the perfect numbers between 1 and 10000. There are only 4 such numbers, the largest being 8128.

3. Write your own version of the strcpy() function, called mystrcpy(). This function should take two strings (char pointers) as input, and copy the second string into the first. Test that your function works properly.

4. Write a C function called strdelete() which takes a string (char pointer) and a character as input. The function should then remove any instance of the character from the string. This should be done by shifting all the other characters down one position in the array so the string becomes shorter. For example strdelete("hello world", 'o') will result in the string being "hell wrld".

In: Computer Science

how can i get the code for this problem in visual basic? Create a Windows Forms...

how can i get the code for this problem in visual basic? Create a Windows Forms applications called ISP (Internet Service Provider) Project. You must enter the number of hours for the month and select your desire ISP package. An ISP has three different subscription packages for it's customers:

Package A: For $9.95 per month 10 hours of access are provided. Additional hours are $2 per hours.
Package B: For $13.95 per month 20 hours of access are provided. Additional hours are $1 per hours.
Package C: For $19.95 per month unlimited access is provided.

The program should also calculates and display the amount of money Package A customers would save if they purchased Package B or C, and the amount of money Package B customers would save if they purchase Package C. If there would be no savings, no message should be displayed.
thank you

can the options be display without using a radio button for the choose

In: Computer Science

Program 3.5 - Conversion Program   - NOW using cin statements to gather input from user Concepts...

Program 3.5 - Conversion Program   - NOW using cin statements to gather input from user

Concepts Covered:  Chapter 2 – cout ,   math, data types, Chapter 3 , gathering both numeric & string input from user

Programs 2-21, 2-22, 2-23, 2-28 should help with math and programs 3.5, 3.17 and 3.19 should help you with the new concepts introduced with this program.

Program Purpose:  To help you understand the concept of using both proper numeric variables and string variables. To give you practice using the C++ math operators. To give you practice getting both numeric input and string input from a user. To give you practice overriding the default behavior of C++ for numeric formatting. Lastly, to appreciate the flexibility of the cout object by passing it string variables, string literals, and numeric variables.

Background:  Your instructor is an avid (some would say obsessed) bicyclist.  Rides of 40 to 50 miles are not uncommon. Your instructor also uses an indoor training program called Zwift. It uses the metric system which is kilometers biked (instead of miles), and meters climbed (instead of feet).     You need to help out your metrically challenged professor and write a conversion program that converts kilometers to miles and meters to feet.

For example, if I told some of my non-biking friends that I rode 40 kilometers, many of them would be impressed.  Well, in miles that is only 24.8 miles.   Conversely, if I told them I climbed 1000 meters they may not be impressed.  But, 1000 meters is 3,280 feet which is not too shabby here in the Midwest.

Oh, did I mention, this also applies to runners, especially in terms of kilometers.

  

So your job commission is to write a C++ program which will convert kilometers to miles and meters to feet.

PROGRAM SPECIFICATIONS:

Insert program heading with your name, course, section, program name, AS WELL AS brief documentation of program purpose at the top of your program.

Create your c++ code.

INPUT SECTION

Create 4 numeric variables to hold the following:  meters, feet, kilometers, and miles.

Create 2 string variables: one to hold the activity type:  biking or running and the other to hold a person’s name.

Prompt the user for their name. You should get the user's full name! Example   Jimmy C   or John Bonham

Prompt the user (using their name) for which activity they did. - biking or running

Prompt the user for how many kilometers

Prompt the user for how many meters they climbed

PROCESSING SECTION

Perform the necessary math operations to convert kilometers to miles and meters to feet.

Kilometers to miles formula:

1 kilometer is equal to 0.621371 miles (often shortened to .62). 1 mile is equal to 1.609344 kilometers. Thus, to convert kilometers to miles, simply multiply the number of kilometers by 0.62137.

Meters to feet formula:

Multiply any meter measurement by 3.28 to convert to feet. Since one meter = 3.28 feet, you can convert any meter measurement into feet by multiplying it by 3.28.

1 meter x 3.28 = 3.28 feet

5 meters x 3.28 = 16.4 feet

2.7 meters x 3.28 = 8.856 feet

OUTPUT SECTION

Using cout statements, display the output listing name, activity, kilometers, miles, meters and feet. For formatting of numeric variables, use 2 digits of precision to right of decimal point.with values shown above.

In: Computer Science

There are two calsses: node.py and a5.py. The a5.py contains three important methods: Length -> Outputs...

There are two calsses: node.py and a5.py. The a5.py contains three important methods:

  • Length -> Outputs the length of the linked list
  • Insert -> Inserts an element into the linked list
  • PrintStructure -> Prints the entire linked list starting from the head

The task is to fill in these methods given in the a5.py. Hints are given to you inside the a5.py class so make sure to check them out. Note that one of the important concepts in this example is that when a new element is inserted into the list, it gets inserted into it’s appropriate (sorted) position. Please take a look at the examples to see how random values are inputted and the result is sorted.

Please enter a word (or just hit enter to end): bottle

Please enter a word (or just hit enter to end): a

Please enter a word (or just hit enter to end): water Please enter a word (or just hit enter to end): of Please enter a word (or just hit enter to end):

The structure contains 4 items: a bottle of water

Please enter a word (or just hit enter to end): Ana

Please enter a word (or just hit enter to end): Bill

Please enter a word (or just hit enter to end): car

Please enter a word (or just hit enter to end): algorithm Please enter a word (or just hit enter to end): button Please enter a word (or just hit enter to end):

The structure contains 5 items: algorithm Ana Bill button car

NODE.PY

"""File: node.py

Node classes for one-way linked structures and two-way

linked structures."""

class Node(object):

def __init__(self, data, next = None):

"""Instantiates a Node with default next of None"""

self.data = data

self.next = next

A5.PY

"""
File: a5.py


Define a length function.
Define a printStructure function.
Define an insert function.
Test the above functions and the Node class.
"""

from node import Node

def length(head):
    """Returns the number of items in the linked structure
    referred to by head."""
    probe = head
    count = 0
   
    # ADD CODE HERE: Count the number of nodes in the structure
   
    return count
   
def insert(newItem, head):
    """Inserts newItem at the correct position (ascending order) in
    the linked structure referred to by head.
    Returns a reference to the new structure."""
    # if head == None:
        # if structure is empty
        # ADD CODE HERE       
    # else:
        #Insert newItem in its place (ascending order)
      # ADD CODE HERE
       
    return head

def printStructure(head):
    """Prints the items in the structure referred to by head."""
    # ADD CODE HERE

def main():
    """Gets words from the user and inserts in the
    structure referred to by head."""
   
    head = None
    userInput = input('Please enter a word (or just hit enter to end): ')
    while userInput != '':
        head = insert(userInput, head)
        userInput = input('Please enter a word (or just hit enter to end): ')
    print('The structure contains', length(head), 'items:')
    printStructure(head)

if __name__ == "__main__": main()

In: Computer Science

Imagine that you are a user in a hurry that types 2O (oh) rather than 20...

Imagine that you are a user in a hurry that types 2O (oh) rather than 20 (zero) as the height. What happens to your program? If the user enters a value that could not be converted to numeric type, allow 3 additional opportunities to enter a new value. If the user fails to enter a correct value after 4 attempts, inform them of such failure and allow the program to end without crashing.

Question: Can someone help me with this?

My original code:

# I put the area calculations of both the triangle and trapezoid up, so that the code could run through them both properly.
def triangle(height, base):
area_triangle = height * base * 0.5
print "the area of your triangle equals %s" % (area_triangle)
def trapezoid(height, base1, base2):
area_trapezoid = ((base1 + base2) / 2) * height
print "the area of your trapezoid equals %s" % (area_trapezoid)
# Giving the option to choose triangle or trapezoid area.
shapes = ["triangle", "trapezoid"]
# I gave my code a title and put my name on it.
print "Area calculator"
print "Made by Alison Voigt"
print "-------------------------------"
# Asking the user to enter either the triangle or the trapezoid to move on to the area calculation.
def calculation():
print "please type the name of your shape"
print "(triangle, trapezoid)"
# Once the user chooses a shape they are asked to enter in the height, and base(s) for the shape of their choosing.
user_shape = raw_input()
if user_shape == shapes[1]:
trapezoid(height = float(raw_input("please type the height of the trapezoid.")), base1 = float(raw_input("please type the base1 length of the trapezoid.")), base2 = float(raw_input("please type the base2 length of the trapezoid.")))
elif user_shape == shapes[0]:
triangle(height = float(raw_input("please type the height of the triangle.")), base = float(raw_input("please type the base length of the triangle.")))
# If the user enters in wrong answer the code will tell you to try again.
else:
print "That's not in the choices!, Try again."
calculation()
# The user is now given the option to calculate the same shape or the other.
calculation()
choice = raw_input("Would you like to calculate the area of a different shape?(yes/no)")
while choice == "yes":
print "---------------------"
calculation()

In: Computer Science

1. If I can assume "not P" and derive "not Q", I have completed an indirect...

1. If I can assume "not P" and derive "not Q", I have completed an indirect proof of the statement "P → Q".

T/F? Why?

2. If I want to prove "P → (x XOR NOT y)", it suffices to prove "P → (x AND y)".

T/F? Why?

3. Suppose I assume "A" and derive "B". Then I start over, assume "not B", and derive a contradiction. Then I may conclude that A is a tautology.

T/F? Why?

4. Suppose I first assume "A xor B" and prove "C".

Then I start over, assume "P", and prove "A and not B".

Finally I start again, assume "Q", and prove "not A and B".

Then I may conclude "(P or Q) → C".

T/F? Why?

5. Suppose I first assume A and derive B.

Then I start over, assume "not C", and derive "not B".

Then I start over, assume "C and not A", and derive "0".

I can now conclude that A, B, and C are all equivalent to one another.

T/F? Why?

In: Computer Science

Discussing - Network Security a) Discuss the relative merits of traditional signature-based IDS/IPS technology with newer...

Discussing - Network Security
a) Discuss the relative merits of traditional signature-based IDS/IPS technology with newer form, such as application awareness and anomaly detection.

b) Discuss and develop a theoretical network architecture for a small business in the area that wishes to expand into new facilities, like a colocation center in the downtown area.

In: Computer Science

Q. In java, I would like to know, especially how the program detect there is an...

Q. In java, I would like to know, especially how the program detect there is an error which is user should put only numerical data but if user put letter data (five, sixty instead of 5,60), *I want the program display "Invalid data. Please try again" instead of long error message(from the IDE)* when user put letter data(five, sixty stuff...) and GO BACK TO THE BEGINNING SO USER CAN PUT THE DATA AGAIN!

Write a program that counts change. The program should ask for the number of quarters, the number of dimes, the number of nickels and the number of pennies. The program should then compute the value of all the coins and tell the user how much money there is, expressed in dollars. Display a title at the top of the screen when the program first runs. You must use constants for the value of each coin type. Multiply the number of each coin times the value for each coin (the defined constant). Refer to the PowerPoint or video on the use of the constants.

1) if quarters =100 dimes = 100 nickels = 100 pennies = 99

=>expected result = 40.99

2) if quarters = hundred dimes = hundred nickels = nine pennies = hundred

=> expected result ""Invalid data. Please try again" (GO BACK TO THE BEGINNING, SO USER CAN PUT THE DATA AGAIN!) <- this is the part i am struggling. Please Help!

In: Computer Science

1. Circle: Implement a Java class with the name Circle. It should be in the package...

1. Circle:

Implement a Java class with the name Circle. It should be in the package edu.gcccd.csis.

The class has two private instance variables: radius (of the type double) and color (of the type String).

The class also has a private static variable: numOfCircles (of the type long) which at all times will keep track of the number of Circle objects that were instantiated.

Construction:

A constructor that constructs a circle with the given color and sets the radius to a default value of 1.0.

A constructor that constructs a circle with the given, radius and color.

Once constructed, the value of the radius must be immutable (cannot be allowed to be modified)

Behaviors:

Accessor and Mutator aka Getter and Setter for the color attribute

Accessor for the radius.

getArea() and getCircumference() methods, hat return the area and circumference of this Circle in double.

Hint: use Math.PI (https://docs.oracle.com/javase/8/docs/api/java/lang/Math.html#PI (Links to an external site.))

2. Rectangle:

Implement a Java class with the name Rectangle. It should be in the package edu.gcccd.csis.

The class has two private instance variables: width and height (of the type double)

The class also has a private static variable: numOfRectangles (of the type long) which at all times will keep track of the number of Rectangle objects that were instantiated.

Construction:

A constructor that constructs a Rectangle with the given width and height.

A default constructor.

Behaviors:

Accessor and Mutator aka Getter and Setter for both member variables.

getArea() and getCircumference() methods, that return the area and circumference of this Rectangle in double.

a boolean method isSquare(), that returns true is this Rectangle is a square.

Hint: read the first 10 pages of Chapter 5 in your text.

3. Container

Implement a Java class with the name Container. It should be in the package edu.gcccd.csis.

The class has two private instance variables: rectangle of type Rectangle and circle of type Circle.

Construction:

No explicit constructors.

Behaviors:

Accessor and Mutator aka Getter and Setter for both member variables.

an integer method size(), that returns 0, if all member variables are null, 1 either of the two member variables contains a value other than null, and 2, if both, the rectangle and circle contain values other than null.

In: Computer Science

Problem 1: More than 2500 years ago, mathematicians got interested in numbers. Armstrong Numbers: The number...

Problem 1:

More than 2500 years ago, mathematicians got interested in numbers.

Armstrong Numbers: The number 153 has the odd property that 13+53 + 33 = 1 + 125 + 27 = 153. Namely, 153 is equal to the sum of the cubes of its own digits.

Perfect Numbers: A number is said to be perfect if it is the sum of its own divisors (excluding itself). For example, 6 is perfect since 1, 2, and 3 divide evenly into 6 and 1+ 2 + 3 = 6.

Input File

The input is taken from a file named number.in and which a sequence of numbers, one per line, terminated by a line containing the number 0.

Output File

All the numbers read from the input file, are printed one per line followed by a sentence indicating whether the number is or is not Armstrong number and whether it is or is not a perfect number. Sample Input 153 6 0 Sample Output 153 is an Armstrong number but it is not a perfect number. 6 is not an Armstrong number but it is a perfect number.

Note: the program must be write in java

In: Computer Science

Identify the major steps involved in the data file update process

Identify the major steps involved in the data file update process

In: Computer Science

Using C++. Write a program to input marks of five subjects Physics, Chemistry, Biology, Mathematics and...

Using C++. Write a program to input marks of five subjects Physics, Chemistry, Biology, Mathematics and Computer. The input marks must be inserted one subject at a time. The program then calculate percentage and grade according to given conditions:

If percentage >= 90% : Grade A

If percentage >= 80% : Grade B

If percentage >= 70% : Grade C

If percentage >= 60% : Grade D

If percentage >= 40% : Grade E

If percentage < 40% : Grade F

Example1: Please input marks of five subjects.

Physics: 95

Chemistry: 95

Biology: 97

Mathematics: 98

Computer: 90

Percentage = 95.00

Grade A

Example2: Please input marks of five subjects.

Physics: 85

Chemistry: 80

Biology: 95

Mathematics: 98

Computer: 70

Percentage = 85.60

Grade B

In: Computer Science

You are to create a page that has four images that are links to other schools...

You are to create a page that has four images that are links to other schools in the New England area. Each image is to be controlled in size by a CSS responsive design. The page is to appear balanced by an appropriate, complimentary, background color. White is not an option as a background color. Look up how to make image links on W3Schools.There is to be a small repeated background image that appears on the right side of the page but not at the edge of the page. There is to be a header banner in a header section (look up "header" tag on W3Schools).The link images are to run vertically down the screen but they may not cover any part of the background image or the header banner.All images are to be in good taste and should represent the site to which they connect. The image does not have to be an exact image of that school but it has to be related.You can't use a fish image to represent a University.

Add an ordered list to your page that will list the current standings of the top eight teams in the National Football League. The list must be styled with CSS and can not use any of the default colors, fonts, or sizes. The first letter of each team's name must be a different color.No content may be against any of the screen edges.Make sure that your submission includes all folders required in your site structure.

In: Computer Science