C++ coding, help
In this program you will be reading numbers from a file. You will validate the numbers and calculate the average of all of the valid numbers.
Your program will read in a file with numbers. The numbers will be of type double.
The numbers should be in the range from 0 to 110 (inclusive). You need to count all of the numbers between 0 and 110. You also need to calculate the average of these numbers.
If a number is not valid (that is, it is less than 0 or greater than 110) you need to count it (as a count of invalid values) and you need to write out the number to a file called "invalid-numbers.txt". Values written to file invalid-numbers.txt should be in fixed format with two digits to the right of the decimal point.
As you did in lab lesson 7 part 1 you need to read in the input file name using cin.
The output from your program will be written to cout. The output must contain the file being processed, the total number of values read in from the file, the number of invalid values read in, the number of valid values read in.
The last thing you need to output is either the average of the valid values or an error message. The average must have two digits of precision to the right of the decimal point and must be in fixed format. If there is not valid average you should output the message:
An average cannot be calculated
In what case would you display this message?
If the input file cannot be opened, you will need to output a message. Assume the input file name is badinput.txt and it cannot be opened. You will display the following error message to cout
File "badinput.txt" could not be opened
Here is an example of a working program:
Assume the file name read in from cin is:
input.txt
and that input.txt contains:
-12
0
98.5
100
105.5
93.5
88
75
-3
111
89
-12
Your program would output the following:
Reading from file "input.txt"
Total values: 12
Invalid values: 4
Valid values: 8
Average of valid values: 81.19
The contents written out to file invalid-numbers.txt are:
-12
-3
111
-12
You are reading from an input file and you are writing to an output file. Make sure you close both files after you are finished using them. You must do this in your program, you cannot just let the operating system close the files for you.
For tests where there is output written to an output file the contents of the output file will determine if you passed that test or not. For cases where you have written out to cout the tests will check the output sent to cout. In some cases output will be written to a file and to cout. When this is the case the test will be run twice with the same input. Once to test cout and once to test the contents of the output file. An example of this would be tests 2 and 3. Both use the same input file. Test 2 check the output written to cout and test 3 checks the output written to the file invalid-numbers.txt.

Answers

Answer 1

Answer:

The program in C++ is as follows:

#include <fstream>

#include <iostream>

#include <iomanip>

using namespace std;

int main() {

 string filename;

 cout<<"Filename: ";

 cin>>filename;

 ifstream inFile(filename);

 if(!inFile) {

   cout << endl << "Cannot open file " << filename;

   return 1;  }  

 ofstream fout;

 ifstream fin;

 fin.open("invalid-numbers.txt");  

 fout.open ("invalid-numbers.txt",ios::app);  

 double sum = 0; int valid = 0; int invalid = 0;

 double num = 0;

 while(!inFile.eof()) {

   inFile >> num;

   if(num >= 0 && num<=110){   sum+=num; valid++; }

else{ invalid++;

if(fin.is_open()){

   fout<<fixed<<setprecision(2)<<num<<"\n";    }  }  }

 fin.close();

 fout.close();

 inFile.close();

 cout<<"Total values: "<<valid+invalid<<endl;

 cout<<"Invalid values: "<<invalid<<endl;

 cout<<"Valid values: "<<valid<<endl;

 cout<<"Average of valid values: "<<fixed<<setprecision(2)<<sum/valid<<endl;    

 double inv;

 ifstream inFiles("invalid-numbers.txt");

 while(!inFiles.eof()) {

   inFiles >> inv;

   cout<<inv<<"\n";

}

inFiles.close();

 return 0;

}

Explanation:

See attachment for source file where comments are used to explain each line


Related Questions

an image can have only one background layer true or false​

Answers

Answer:

True

Explanation:

The background will always just be the background. You cannot blend two images together to make two background because it would be considered one background nonetheless.

Crop-Harvesting robots manage harvest automation, seeding, and weeding.
True
False

Answers

Answer: False

Explanation: I think there are specific robots for seeding, weeding and harvest automation. Unless its a multi purposed crop-harvesting robot I would assume it would only be related to harvesting tasks. (picking)

More info here: https://www.ncbi.nlm.nih.gov/pmc/articles/PMC7273211/

the first page of a website is what?​

Answers

Answer:

index.html

Explanation:

The name of the html file for the homepage of a website is usually "index.html"

Landing page or Home page

Rick is a fan of logic-based games. However, he is bored of the classic ones, like Sudoku and Mastermind, since he has solved so many of them. Recently he found a new game in which one is given a string with some question marks in it. The objective is to replace all of the question marks with letters (one letter per question mark) in such a way that no letter appears next to another letter of the same kind.
Write a function:
def solution(riddle)
that, given a string riddle, returns a copy of the string with all of the question marks replaced by lowercase letters (a-z) in such a way that the same letters do not occur next to each other. The result can be any of the possible answers as long as it fulfils the above requirements.
Examples:
1. Given riddle = "ab?ac?", your function might return "abcaca". Some other possible results are 'abzacd", "abfacf".
2. Given riddle = "rd?e?wg??", your function might return "rdveawgab".
3. Given riddle = "????????", your function might return "codility".
Write an efficient algorithm for the following assumptions:
• the length of the string is within the range [1..100,000);
• string riddle consists only of lowercases letters (a - z) or '?';
• it is always possible to turn string 'riddle' into a string without two identical consecutive letters.
1 # you can write to stdout for debugging purposes, e.g.
2 # print("this is a debug message")
3
4 def solution (riddle):
5
6 # write your code in Python 3.6
7 pass

Answers

Answer:

The function is as follows:

import random

import string

def solution(riddle):

   s = list(riddle)

   for i in range(len(riddle)):

       alpha = "".join(random.choice(string.ascii_letters) for x in range(1))

       alpha = alpha.lower()

       if s[i] == '?':

           if i > 0 and i < len(s)-1:

               if s[i+1] != alpha:

                   s[i] = alpha

               elif s[i-1] != alpha:

                   s[i] = alpha

               else:

                   i=i

           else:

               if i == 0:

                   if s[1] != alpha:

                       s[i] = alpha

                   else:

                       i = i

               else:

                   if s[i-1] != alpha:

                       s[i] = alpha

                   else:

                       i = i

   riddle = ""

   for ele in s:

       riddle+=ele

   

   return riddle

Explanation:

See attachment for explanation where comments are used to explain some lines

In this exercise we have to use the knowledge of the python language to write the code, so we have to:

The code is in the attached photo.

So to make it easier the code can be found at:

import random

import string

def solution(riddle):

  s = list(riddle)

  for i in range(len(riddle)):

      alpha = "".join(random.choice(string.ascii_letters) for x in range(1))

      alpha = alpha.lower()

      if s[i] == '?':

          if i > 0 and i < len(s)-1:

              if s[i+1] != alpha:

                  s[i] = alpha

              elif s[i-1] != alpha:

                  s[i] = alpha

              else:

                  i=i

          else:

              if i == 0:

                  if s[1] != alpha:

                      s[i] = alpha

                  else:

                      i = i

              else:

                  if s[i-1] != alpha:

                      s[i] = alpha

                  else:

                      i = i

  riddle = ""

  for ele in s:

      riddle+=ele

  return riddle

See more about python at brainly.com/question/26104476

Which of the following is the cause of transmission impairment?
Select one:
O Frequency
O Amplitude
O Attenuation
O Phase​

Answers

Answer:

Attenuation is the cause of transmission impairment.

hope it is helpful to you

def shared_motif(dna_list):
This function takes in a list of DNA strings and returns the longest common substring. A substring is a contiguous sequence of characters within a string. A common substring is a substring of every element in the given list of DNA strings. Note that the number of DNA strings in the input list is not always the same! There may be multiple solutions, but you only need to return the first one.
Example:
Sample input DNA list:
("GATTACA", "TAGACCA", "ATACA"]
The returned longest common substring:
"TA"

Answers

Answer:

Explanation:

The following code is written in Python, the function creates various nested loops to loop through each individual string comparing letter by letter in order to find the longest common substring. Finally, returning the substring itself.

def shared_motif(dna_list):

   substr = ''

   if len(dna_list) > 1 and len(dna_list[0]) > 0:

       for x in range(len(dna_list[0])):

           for i in range(len(dna_list[0]) - x + 1):

               if i > len(substr) and all(dna_list[0][x:x + i] in y for y in dna_list):

                   substr = dna_list[0][x:x + i]

   return substr

arr = ["GATTACA", "TAGACCA", "ATACA"]

stems = shared_motif(arr)

print(stems)

Mark is six years younger than his sister Teri. Their combined ages equals 86. How old are Mark and Teri?
Mark's age = x
Teri's age = y​

Answers

Answer:

x = 40

y = 46

Explanation is in the image above.

Create a PetStore class, a Dog class, and Cat class. Once instantiated, a PetStore should be able to take in and give out pets. The store's method for receiving pets should be called receive. This method should take a single pet object (either a Dog or Cat instance) and should add it to the store's inventory of pets. The store's method for giving out a pet should be called sell and can take no arguments. The method returns a pet when called.

Answers

Answer:

thanks to the great place

Explanation:

hottest year in hindi history and happiness and the world is not a big deal to me because I think it's a good thing for a woman who has been a good friend of yours and happiness and be happy with examples

HOW TO DOWNLOAD BEAMNG DRIVE

Answers

Explanation:

Answer:

Explanation:

on what device

short note about micro miniaturzation​

Answers

Answer:

the manufacture of extremely small versions of electronic devices.

Explanation:

asks

mxskssssksskwlwslskamzmzmsmsmz

how do engineers communicate their design ideas?

Answers

Answer:

Explanation:

Mechanical engineers give Presentations when they work on projects and Proposals. Often, professional Presentations require you to verbally and graphically present preliminary designs to colleagues.

Hope this helped!!!

You use the fixed manipulator to Group of answer choices round floating-point numbers that are displayed in fixed-point notation to the specified number of decimal places round floating-point numbers that are displayed in scientific notation to the specified number of significant digits format floating-point numbers in fixed-point notation all of the above a and b only

Answers

Answer:

format floating-point numbers in fixed-point notation

Explanation:

Required

Function of fixed manipulator

This question will be answered from the perspective of C++ programming language (however, the explanation is applicable to programming languages that uses fixed manipulators)

Fixed manipulators in C++ is used to set floating point numbers to a stated  fixed point.

Take for instance;

double pi = 3.1415926534;

cout.precision(2);

cout<< fixed << pi;

The third line of the program where the fixed manipulator is used to format pi to 2 fixed point notation.

Hence, the output will be 3.14

A train protection system automatically applies the brakes of a train if the speed limit for a segment of track is exceeded, or if the train enters a track segment that is currently signaled with a red light (i.e., the segment should not be entered). There are two critical-safety requirements for this train protection system:
The train shall not enter a segment of track that is signaled with a red light.
The train shall not exceed the specified speed limit for a section of track.
Assuming that the signal status and the speed limit for the track segment are transmitted to on-board software on the train before it enters the track segment, propose five possible functional system requirements for the onboard software that may be generated from the system safety requirements.

Answers

Explanation:

Five possible functional system requirements for the onboard software that may be generated from the system safety requirements:

software should enable the brakes to be applied instantly when the red light is signaled.speed of the train should be monitored when it's running on a segment so that it does not exceed the maximum speed limit.important for the system to examine the color displayed before a train enters a segment of the track.constant checking of the speed limit and color of the light so as to determine when the brakes should be applied. when there is a red light the system should notify/prevent the train from entering the segment.

Python program
You are given the following text file called Mytext.txt. Write a Python function called search_file that accepts the name of the file (i.e. filename) and a string to look for in the file (i.e. mystring) as parameters. The function then looks for mystring in the file. Whenever it finds the string in a line, it saves the line number and the text for that line in a dictionary. Finally, it returns the dictionary after reading all the lines in the file and populating the dictionary with all matching line numbers and line text. If an empty string or a blank string is passed as mystring then an empty dictionary is returned.
Sample Input: search_file("Mytext.txt","python")
Sample Input: search_file("Mytext.txt","")
Contents of Mytext.txt
Python is an interpreted, high-level, programming language.
Python is dynamically typed and garbage-collected.
Python was conceived in the late 1980s.
Python 2.0, was released in 2000.
Python 3.0, was released in 2008.
The interpreters are available for many operating systems.

Answers

Answer:

The function in Python is as follows:

def search_file(filename,mystring):

my_dict = {}

count = 0

file = open(filename)

lines = file.readlines()

for line in lines:

 count+=1

 if mystring.lower() in line.lower():

  my_dict[count] = line.rstrip('\n')

return my_dict

Explanation:

This defines the function

def search_file(filename,mystring):

This initializes an empty dictionary

my_dict = {}

This initializes the number of lines to 0

count = 0

This opens the file

file = open(filename)

This reads the lines of the file

lines = file.readlines()

This iterates through the lines

for line in lines:

This increments the number line

 count+=1

This checks if the string exists in the line

 if mystring.lower() in line.lower():

If yes, the line number and the string are added to the dictionary

  my_dict[count] = line.rstrip('\n')

This returns the dictionary

return my_dict

6.12 LAB: Warm up: Parsing strings (1) Prompt the user for a string that contains two strings separated by a comma. (1 pt) Examples of strings that can be accepted: Jill, Allen Jill , Allen Jill,Allen Ex: Enter input string: Jill, Allen (2) Report an error if the input string does not contain a comma. Continue to prompt until a valid string is entered. Note: If the input contains a comma, then assume that the input also contains two strings. (2 pts)

Answers

Answer:

Explanation:

The following code is written in Python. It is a loop that asks the user for an input. If it contains a comma then it removes whitespace, splits it into two words, and prints each word seperately, and exits the loop. If it does not contain a comma then it prompts the user for another input.

while True:

   string = input("Enter input string: ")

   if ',' in string:

       string = string.replace(" ", '')

       string_split = string.split(',')

       print("First word: " + string_split[0])

       print("Second word: " + string_split[1])

       break

For the recursive method below, list the base case and the recursive statement, then show your work for solving a call to the recur() method using any parameter value 10 or greater.

public static int recur(int n)
{
if(n < 1)
{
return 3;
}
else
{
return recur(n / 5) + 2;
}
}

Answers

Answer:

(a): The base case: if(n<1)

(b): The recursive statement: recur(n / 5)

(c): Parameter 10 returns 7

Explanation:

Given

The above code segment

Solving (a): The base case:

The base case is that, which is used to stop the recursion. i.e. when the condition of the base case is true, the function is stopped.

In the given code, the base case is:

if(n<1)

Solving (b): The recursive statement:

The recursive statement is the statement within the function which calls the function.

In the given code, the recursive statement is:

recur(n / 5)

Solving (c): A call to recur() using 10

The base case is first tested

if (n < 1); This is false because 10 > 1

So, the recursive statement is executed

recur(n/5) +2=> recur(10/5)+2 => recur(2)+2

2 is passed to the function, and it returns 2

if (n < 1); This is false because 2 > 1

So, the recursive statement is executed

recur(n/5) +2=> recur(2/5)+2 => recur(0)+2

2 is passed to the function, and it returns 2

if (n < 1); This is true because 0 < 1

This returns 3

So, the following sum is returned

Returned values = 2 + 2 + 3

Returned values = 7

What is the main fuction of command interpreter​

Answers

The command interpreter or the command-line interface is one of the ways a user can interface with the operating system. The command interpreter's main task is to understands and executes commands which it turns into system calls. The kernel is the central module of an OS.

_________________

Brainliest would be greatly appreciated!

I found this!

_________________

#SpreadTheLove

#SaveTheTrees

- Mitsu JK

PLEASE HELP ME FIX THIS CODE.

I WANT IT TO HAVE USER INPUT TO CHANGE AND IMAGE FILTER TO BLUE RED OR GREEN.


user_color = input("What color would you like to paint the canvas, blue, red or green?:")



def user_red(pixel):
pixel[0] = 100 + pixel[0]
pixel[1] = 100 - pixel[1]
pixel[2] = 100 - pixel[2]

return pixel

def user_green(pixel):
pixel[0] = 100 + pixel[0]
pixel[1] = 100 - pixel[1]
pixel[2] = 100 - pixel[2]

return pixel

def user_blue(pixel):
pixel[0] = 100 + pixel[0]
pixel[1] = 100 - pixel[1]
pixel[2] = 100 - pixel[2]

return pixel


def custom_filter(image, user_color):
for x in range(image.get_width()):
for y in range(image.get_height()):
pixel = image.get_pixel(x,y)
new_colors = invert_pixel(pixel)
image.set_red(x, y, new_colors[0])
image.set_green(x, y, new_colors[1])
image.set_blue(x, y, new_colors[2])



return image


def change_image():
global image
image = custom_filter(image, user_color)



timer.set_timeout(change_image, IMAGE_LOAD_TIME)

Answers

PLEASE HELP ME FIX THIS CODE.

I WANT IT TO HAVE USER INPUT TO CHANGE AND IMAGE FILTER TO BLUE RED OR GREEN.

user_color = input("What color would you like to paint the canvas, blue, red or green?:")

def user_red(pixel):

pixel[0] = 100 + pixel[0]

pixel[1] = 100 - pixel[1]

pixel[2] = 100 - pixel[2]

return pixel

def user_green(pixel):

pixel[0] = 100 + pixel[0]

pixel[1] = 100 - pixel[1]

pixel[2] = 100 - pixel[2]

return pixel

def user_blue(pixel):

pixel[0] = 100 + pixel[0]

pixel[1] = 100 - pixel[1]

pixel[2] = 100 - pixel[2]

return pixel

def custom_filter(image, user_color):

for x in range(image.get_width()):

for y in range(image.get_height()):

pixel = image.get_pixel(x,y)

new_colors = invert_pixel(pixel)

image.set_red(x, y, new_colors[0])

image.set_green(x, y, new_colors[1])

image.set_blue(x, y, new_colors[2])

return image

def change_image():

global image

image = custom_filter(image, user_color)

timer.set_timeout(change_image, IMAGE_LOAD_TIME)

cmo se puede añadir amigo ??'

Answers

Answer:ok

Explanation:

is the minimum level of security mechanism in a
system.
Select one:
O Baseline
O Security model
O Security policy
O Reconnaissance​

Answers

Answer:

Security policy is the minimum

Explanation:

Which of the following best explains how an analog audio signal is typically represented by a computer?
a. An analog audio signal is measured at regular intervals. Each measurement is stored as a sample, which is represented at the lowest level as a sequence of bits.
b. An analog audio signal is measured as a sequence of operations that describe how the sound can be reproduced. The operations are represented at the lowest level as programming instructions.
c. An analog audio signal is measured as input parameters to a program or procedure. The inputs are represented at the lowest level as a collection of variables.
d. An analog audio signal is measured as text that describes the attributes of the sound. The text is represented at the lowest level as a string.

Answers

Answer:

A. An analog audio signal is measured at regular intervals. Each measurement is stored as a sample, which is represented at the lowest level as a sequence of bits.

Explanation:

I took the test

To specify the data sets you want to see for your particular user, you create or select a
d
Select one:
a. Filter
b. View
c. Switch
d. Scope

Answers

Answer:

B

Explanation:

A security team has downloaded a public database of the largest collection of password dumps on the Internet. This collection contains the cleartext credentials of every major breach for the last four years. The security team pulls and compares users' credentials to the database and discovers that more than 30% of the users were still using passwords discovered in this list. Which of the following would be the BEST combination to reduce the risks discovered?

a. Password length, password encryption, password complexity
b. Password complexity least privilege, password reuse
c. Password reuse, password complexity, password expiration
d. Group policy, password history, password encryption

Answers

Answer:

a. Password length, password encryption, password complexity

Explanation:

Under this scenario, the best combination would be Password length, password encryption, password complexity. This is because the main security problem is with the user's passwords. Increasing the password length and password complexity makes it nearly impossible for individuals to simply guess the password and gain access, while also making it extremely difficult and time consuming for hackers to use software to discover the password as well. Password excryption would be an extra layer of security as it encrypts the password before storing it into the database, therefore preventing eavesdroppers from seeing the password and leaked info from being used without decryption.

Code.org lesson 8 level 5

Answers

Answer:

and?

Explanation:

When dragging a sheet tab to move it, the location of the _______ determines where the sheet tab will be moved.

square
line
arrow
last tab

Answers

the location of the arrow determines it

Define a structure Triangle that contains three Point members. Write a function that computes the perimeter of a Triangle . Write a program that reads the coordinates of the points, calls your function, and displays the result

Answers

Answer:

The program in C++ is as follows:

#include <iostream>    

using namespace std;

int perimeter(int side1, int side2, int side3){

return side1+side2+side3;

}

struct Triangle  {

int side1;  int side2;   int side3;

};

int main(void) {

int side1, side2, side3;

cout<<"Sides of the triangle: ";

cin>>side1>>side2>>side3;

struct Triangle T;

T.side1 = side1;

T.side2 = side2;

T.side3 = side3;  

cout << "Perimeter: " << perimeter(T.side1,T.side2,T.side3) << endl;

return 0;

}

Explanation:

See attachment for complete code where comments are as explanation

what does this mean on a tamagotchi lol (this is the hello kitty one)

Answers

I not sure but I think it’s an apple.

I don't have that tamagotchi

But I do have 2 tamagotchi's

I think it's a cherry on your tamagotchi

Hoped this helped!

Have a wonderful day-

A decimal number is called a float.
True
False

Answers

Answer: True

Explanation:

The term floating point is derived from the fact that there is no fixed number of digits before and after the decimal point; that is, the decimal point can float. There are also representations in which the number of digits before and after the decimal point is set, called fixed-pointrepresentations.

Answer:

It's true

Explanation:

Design a class named Complex for representing complex numbers and the methods add, subtract, multiply, divide, abs for performing complex-number operations, and override toString method for returning a string representation for a complex number. The toString method returns a + bi as a string. If b is 0, it simply returns a.
Provide three constructors Complex(a, b), Complex(a), and
Complex(). Complex() creates a Complex object for number 0 and
Complex(a) creates a Complex object with 0 for b. Also provide
the getRealPart() and getImaginaryPart() methods for returning
the real and imaginary part of the complex number, respectively.
Your Complex class should also implement the Cloneable
interface.
Write a test program that prompts the user to enter two complex numbers and display the result of their addition, subtraction, multiplication, and division.
Here is the main class. It cannot be changed.
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Enter the first complex number: ");
double a = input.nextDouble();
double b = input.nextDouble();
Complex c1 = new Complex(a, b);
System.out.print("Enter the second complex number: ");
double c = input.nextDouble();
double d = input.nextDouble();
Complex c2 = new Complex(c, d);
System.out.println("(" + c1 + ")" + " + " + "(" + c2 + ")" + " = " + c1.add(c2));
System.out.println("(" + c1 + ")" + " - " + "(" + c2 + ")" + " = " + c1.subtract(c2));
System.out.println("(" + c1 + ")" + " * " + "(" + c2 + ")" + " = " + c1.multiply(c2));
System.out.println("(" + c1 + ")" + " / " + "(" + c2 + ")" + " = " + c1.divide(c2));
System.out.println("|" + c1 + "| = " + c1.abs());
Complex c3 = (Complex)c1.clone();
System.out.println(c1 == c3);
System.out.println(c3.getRealPart());
System.out.println(c3.getImaginaryPart());
}
}

Answers

Answer:

Explanation:

The following code is written in Java, it creates the entire complex class as requested so that it works with the main method that has been provided in the question without having to change anything in the main method. Proof of output can be seen in the attached picture below

import java.util.Scanner;

class Test implements Cloneable{

   public static void main(String[] args) {

       Scanner input = new Scanner(System.in);

       System.out.print("Enter the first complex number: ");

       double a = input.nextDouble();

       double b = input.nextDouble();

       Complex c1 = new Complex(a, b);

       System.out.print("Enter the second complex number: ");

       double c = input.nextDouble();

       double d = input.nextDouble();

       Complex c2 = new Complex(c, d);

       System.out.println("(" + c1 + ")" + " + " + "(" + c2 + ")" + " = " + c1.add(c2));

       System.out.println("(" + c1 + ")" + " - " + "(" + c2 + ")" + " = " + c1.subtract(c2));

       System.out.println("(" + c1 + ")" + " * " + "(" + c2 + ")" + " = " + c1.multiply(c2));

       System.out.println("(" + c1 + ")" + " / " + "(" + c2 + ")" + " = " + c1.divide(c2));

       System.out.println("|" + c1 + "| = " + c1.abs());

       Complex c3 = c1;

       System.out.println(c1 == c3);

       System.out.println(c3.getRealPart());

       System.out.println(c3.getImaginaryPart());

   }

}

class Complex implements Cloneable {

   public interface Cloneable { }

   private double realPart;

   public double getRealPart() {

       return realPart;

   }

   public void setReal(double real) {

       this.realPart = real;

   }

   private double imaginaryPart;

   public double getImaginaryPart() {

       return imaginaryPart;

   }

   public void setImaginary(double imaginary) {

       this.imaginaryPart = imaginary;

   }

   public Complex(double a, double b) {

       realPart = a;

       imaginaryPart = b;

   }

   public Complex(double a) {

       realPart = a;

       imaginaryPart = 0;

   }

   public Complex() { }

   public Complex add(Complex comp2) {

       double real1 = this.getRealPart();

       double real2 = comp2.getRealPart();

       double imaginary1 = this.getImaginaryPart();

       double imaginary2 = comp2.getImaginaryPart();

       return new Complex(real1 + real2, imaginary1 + imaginary2);

   }

   public Complex abs() {

       double real1 = Math.abs(this.getRealPart());

       double imaginary1 = Math.abs(this.getImaginaryPart());

       return new Complex(real1, imaginary1);

   }

   public Complex subtract(Complex comp2) {

       double real1 = this.getRealPart();

       double real2 = comp2.getRealPart();

       double imaginary1 = this.getRealPart();

       double imaginary2 = comp2.getRealPart();

       return new Complex(real1 - real2, imaginary1 - imaginary2);

   }

   public Complex multiply(Complex comp2) {

       double real1 = this.getRealPart();

       double real2 = comp2.getRealPart();

       double imaginary1 = this.getRealPart();

       double imaginary2 = comp2.getRealPart();

       return new Complex(real1 * real2, imaginary1 * imaginary2);

   }

   public Complex divide(Complex comp2) {

       double real1 = this.getRealPart();

       double real2 = comp2.getRealPart();

       double imaginary1 = this.getRealPart();

       double imaginary2 = comp2.getRealPart();

       return new Complex(real1 / real2, imaginary1 / imaginary2);

   }

   public String toString() {

       String result;

       result = realPart + " + " + imaginaryPart + "i";

       return result;

   }

}

write a complete program for the following situation related to the setting the speed of a car preset values before starting journey. . if speed is less than lower_set_speed, display the message "accelerate" to the screen, increases the cars speed to the lower set speed and output the new speed to screen .if speeds greater than upper_set_ speed, print the message "apply brake" to the new speed to the screen .Give all necessary documentation in the comments, including the file name. .allow the program to exit at the end. .output the speed to the screen. . how many different initial speeds will you need to test this code?

please help me it means a lot​

Answers

Answer:

Explanation:

Please specify which programming language this is supposed to be written in.

Without knowing that, only the last part can be answered "how many different initial speeds will you need to test this code?"

You will need to test at least 3 initial speeds: one below the lower-set-speed, one between the lower- and upper-set-speed and last one which is above the upper-set-speed.

Other Questions
Find the area of the figure Testing is the only way to know for sure if you have HIV. Knowing your status means you can keep yourself and your sexual partners healthy. Being diagnosed early gives you a better chance of living a long and healthy life. Rewrite the expression without parentheses. 13m(3+8m) Help me please I dont understand this find endpoint T, given an endpoint S (-2, 9) and Midpoint M (8, 0) Which God/Goddess works against Odysseus? help a girl pass her math test pleaseee A CD manufacturer wanted to determine which of two different cover designs for a newly released CD will generate more sales. The manufacturer chose 70 stores to sell the CD. Thirty-five of these stores were randomly assigned to sell CDs with one of the cover designs and the other 35 were assigned to sell the CDs with the other cover design. The manufacturer recorded the number of CDs sold at each of the stores and found a significant difference between the mean number of CDs sold for the two cover designs. Which of the following gives the conclusion that should be made based on the results and provides the best explanation for the conclusion?A. It is NOT reasonable to conclude that the difference in sales was caused by the different cover designs because this was not an experiment.B. It is NOT reasonable to conclude that the difference in sales was caused the different cover designs because there was no control group for comparison.C. It is NOT reasonable to conclude that the difference in sales was caused the different cover designs because the 70 stores were not randomly chosen.D. It is reasonable to conclude that the difference in sales was caused by the different cover designs because the cover designs were randomly assigned to stores.E. It is reasonable to conclude that the difference in sales was caused by the different cover designs because the sample size was large. 8. Two months after President Martin Van Buren took office, the United Statesentered inA. a severe depression.B. a light recession.C. an international profit trade era.D. a prosperity era. PLEASE HELP Balance this equation.___PH3 -> ___ P2 + H2 What evidence does Taizong use to support his argument?the indication that all people can learn military artsthe fact that war leads to a declining populationthe rules of military forcea quote from Confucius SOMEONE SMART PLEASE HELPI HAVE 5 MINS LEFT FOR THIS IS IT CORRECT? pls help it's due in 10 minuets!!!(Word Choices)- ceremonious, bier, commerce, indispensable, labor-intensive, manpower, low-end, rejects, draw, triangulated1. The outlet sold ____ that were not good enough for regular stores.2. Many firms meet their changing ____ needs by hiring temporary workers3. The growth of small businesses insured that ____ would be an important part of the city's economy.4. The Office of Protocol at the Department takes care of organizing ____ receptions for visiting foreign dignitaries. HELP I NEED HELP ASAP HELP I NEED HELP ASAP HELP I NEED HELP ASAP HELP I NEED HELP ASAP HELP I NEED HELP ASAP SOMEONE HELP FAST!!!rewrite the sentence and placing the direct object in the correct spot 9. Yo llamo a mi hermano Luis10. Los nios quieren a sus abuelos.11. T buscas a tu perro.12 El piloto conduce el avin What pressure, in atm, will be exerted by 8 moles of a gas at 300Kelvin if it is contained in a 50 Liter vessel? Stella, age 38, is single with no dependents. The following information was obtained from her personal records for the 2020 year. Salary $30,000 Interest income 7,000 Alimony received 12,000 Individual retirement account contribution 2,000 Home mortgage interest expense 4,000 Property taxes 2,000 Personal casualty loss in a Federal disaster area (after the $100 floor) 38,000 Stolen investment property 16,000 Unreimbursed employee business loss 3,000Based on the above information, what is Stellas net operating loss for 2015? NEED HELP ASAP ; How did the U.S. government address the Kings concerns in the letter of Birmingham jail (AP GOV) Let f(x)=x^2+2 and g(x)=1-3x. Find each function value: f(g(-1)) What US medical agency recently revised its guidance on cleaning surfaces with disinfectant