Convert the program below with both value-returning and void functions (1 program only) #include using namespace std; int main() { double first=0.0, second=0.0, total=0.0; cout << "What is the first number?"; cin>>first; cout<<"What is the second number?"; cin>>second; total = first + second; cout<<"Total="<

Respuesta :

Answer:

Hi, the question is incomplete. You didn't provide the full program code and what to do,on it.

First, I'll complete the program code.

But it's obvious the code is written in C++ language.

Using the "CONVERT" keywords in your question, I'll convert the question to a functional program in C++ and I'll also convert the completed code to another programming language (java).

Explanation:

Complete Code

#include <iostream>

using namespace std;

int main() {

double first=0.0, second=0.0, total=0.0;

cout << "What is the first number?";

cin>>first;

cout<<"What is the second number?";

cin>>second;

total = first + second;

cout<<"Total="<<total;

return 0;

}

Functional Program

double TotalSum(double n1, double n2);

void main(void)

{

double first;

double second;

double Sum;

cout << "What is the first number?";

cin >> first;

count<<"What is the second number?";

cin>> second;

//Call the function in an assignment expression

Sum = TotalSum(first, second);

cout<<"Total= "<<Sum;

}

// function definition

double TotalSum(double n1, double n2)

{

return n1 + n2;

}

Same Program in another programming language (Java)

import java.util.*;

public class Addition{

public static void main (String [] args){

double first, second,total;

Scanner input = new Scanner(System.in);

System.out.println("What is the first number?");

first = input.nextDouble();

System.out.println("What is the second number?");

second = input.nextDouble();

total = first + second;

System.out.print("Total ="+total);

}