1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
tatuchka [14]
3 years ago
9

Given that a function receives three parameters a, b, c, of type double, write some code, to be included as part of the function

, that determines whether the value of "b squared" – 4ac is negative. If negative, the code prints out the message "no real solutions" and returns from the function.
Computers and Technology
1 answer:
Ray Of Light [21]3 years ago
4 0

Answer:

The function, having three double parameters, for the given scenario in c++ is given below.

void calc(double a, double b, double c)

{

   double res, s;

   s = b*b;

   res = s - (4*a*c);

   if(res < 0)

       cout << "no real solutions" << endl;

}

Explanation:

A function is declared as follows.

return-type function-name (parameter1, parameter2, … )

1. The return-type can be void or any other data type in c++ language. Void indicates that the function does not returns anything. Other data types indicate that the function returns a value of that particular data type.

2. Here, the return type is taken as void since question does not asks to return any value from the function.

3. The function-name is the name of the function. The naming conventions are similar to those defined for variables in c++.

4. The brackets following the function-name consists of the parameters. The parameters are optional and the bracket can be empty.

5. The parameters are declared in the same way as the normal variables.

The function executes as explained.

1. The function calc() receives three double parameters a, b and c.

2. No user input is taken inside the function.

3. Two additional variables are declared which are used as given below. These variables are also declared as double.

4. Square of value in variable b is stored in the variable, s.

5. The final value of the expression, s - 4ac (equivalent to b squared – 4ac), is stored in the variable, res.

6. If the value of variable res is less than 0 or negative, the function displays a message, “no real solutions” to the standard output.

7. If the value of variable res is more than or equal to 0, the function does not display any message to the standard output.

8. As per the question, message should be displayed only for the negative value of the expression.

You might be interested in
A bag of cookies holds 40 cookies. The calorie information on the bag claims that there are 10 servings in the bag and that a se
laila [671]

Answer:

import java.util.Scanner;

public class ANot {

   public static void main(String[] args) {

   Scanner in = new Scanner (System.in);

       System.out.println("How many cookies did you eat today");

       int numOfCookies = in.nextInt();

       double numCalories = (numOfCookies*300)/4;

       System.out.println("The total number of calories you consumed in "+numOfCookies+" cookies is " +

               " "+numCalories);

   }

}

Explanation:

This code is implemented in Java.

  1. We know from the question that 4 cookies contain 300 calories
  2. Therefore number of calories consumed = (number of cookies eaten*300)/4
  3. To implement this in java we used the scanner class to prompt user for the input
  4. save the input to a variable and write mathematical expression for the number of calories consumed
  5. Then output the result

4 0
3 years ago
In this lab, you will build a system for package delivery services that provides different shipping options with specific price.
Alex73 [517]

Answer:

See explaination

Explanation:

#include <iostream>

#include <string.h>

using namespace st d;

class Package

{

protected:

//sender properities

char sname[10],saddress[50],scity[20],sstate[20];

long int szip;

//Receiver properities

char rname[10],raddress[50],rcity[20],rstate[20];

long int rzip;

//additonal datamembers

float weight,cost;

public:

Package() //Default constructor

{

strcpy(sname,"");strcpy(saddress,"");strcpy(scity,"");

strcpy(sstate,"");szip=0;

strcpy(rname,"");strcpy(raddress,"");strcpy(rcity,"");

strcpy(rstate,"");rzip=0;

weight=cost=0;

}

Package(char sn[10],char sa[50],char sc[20],char ss[20],long int sz,char rn[10],char ra[50],char rc[20],char rs[20],long int rz,float w,float c) //Constructor with parameter

{

strcpy(sname,sn);strcpy(saddress,sa);strcpy(scity,sc); //copying each parameter value to data member

strcpy(sstate,ss);szip=0;

strcpy(rname,rn);strcpy(raddress,ra);strcpy(rcity,rc);

strcpy(rstate,rs);rzip=0;

weight=w;cost=c;

}

float calculateCost() //calculating cost

{

return weight*cost;

}

};

class TwoDayPackage:public Package //Inheritance

{

float flatfee;

public:

TwoDayPackage(char sn[10],char sa[50],char sc[20],char ss[20],long int sz,char rn[10],char ra[50],char rc[20],char rs[20],long int rz,float w,float c,float ff) //Constructor with parameter

{

Package(sn,sa,sc,ss,sz,rn,ra,rc,rs,rz,w,c); //calling super class constructor

flatfee=ff; //copy last parameter

}

float calculateCost() //redefined calculateCost function

{

return (weight*cost)+flatfee; //return total cost

}

};

class OverNightPackage:public Package //Inheritance

{

float addfee;

public:

OverNightPackage(char sn[10],char sa[50],char sc[20],char ss[20],long int sz,char rn[10],char ra[50],char rc[20],char rs[20],long int rz,float w,float c,float a f) //constructor with parameter

{

Package(sn,sa,sc,ss,sz,rn,ra,rc,rs,rz,w,c); //calling super class constructor

addfee=a f; //copy last parameter

}

float calculateCost() //redefined calculateCost function

{

return (weight*cost)+addfee; //calculating total cost

}

};

int main()

{

Package package1("lou brown","1 main st","boston","ma",11111,"mary smith","7 elm st","new york","ny",22222,8.5,0.5); //creating objects

TwoDayPackage package2("lisa klein", "5 broadway", "somerville", "ma", 33333, "bob george", "21 pine rd", "cambridge", "ma", 44444, 10.5, .65, 2.0 );

OverNightPackage package3 ("ed lewis", "2 oak st", "boston", "ma", 55555, "don kelly", "9 main st", "denver", "co", 66666, 12.25, .7, .25 );

cout<<"\nPackage Cost : "<<package1.calculateCost(); //calling each cost

cout<<"\nTwoDay Package Cost : "<<package2.calculateCost();

cout<<"\nOvernight Package Cost : "<<package3.calculateCost();

return 0;

}

8 0
3 years ago
True or False: F Layout is better for users who read left to right, but layout is better for users who read right to left.
ipn [44]

Answer:

false

Explanation:

it depends on the user

5 0
2 years ago
What tab should you choose if you want to practice presenting with your PowerPoint slides?
dezoksy [38]

Answer:

i think its slideshow tab

Explanation:

tell me if im right

6 0
2 years ago
Read 2 more answers
If you're searching for a date and a product at the same time, you're running a _______ query. A. Complex B. Select C. Parameter
Andrews [41]

If you're searching for a date and a product at the same time, you're running a _______ query. A. Complex B. Select C. Parameter D. Range                                                                                                                                                                                                                                                         A. Complex

6 0
3 years ago
Other questions:
  • What is the height of the tallest possible red-black tree containing 31 values?
    7·1 answer
  • I would A lot of knowledge and education for computers and <br> Technology
    10·2 answers
  • Microsoft has developed the Active Directory Domain structure so that a central authority, called the __________, is the reposit
    7·1 answer
  • What is E-Commerce? Answer The Following. Pls Help Me​
    5·1 answer
  • Que es tarjeta madre resumen porfa
    13·2 answers
  • X = 10<br> y = 20<br> x &gt; y<br> print("if statement")<br> print("else statement")
    6·1 answer
  • Wht is these things Aᔑ bʖ cᓵ d↸ eᒷ f⎓ g⊣ h⍑ i╎
    15·2 answers
  • What is the first things u do upon seeing this sheet?​
    14·2 answers
  • QUESTION 5
    9·1 answer
  • Explain different users of computer in briefly?​
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!