Question

Using your programming language of choice, write a program that will ask for: Probability of A...

Using your programming language of choice, write a program that will ask for:

  • Probability of A
  • Probability of B
  • Probability of B given A

and will then output the probability of A given B using Bayes Theorem. You can prompt for input anyway you like (command line, GUI, website, etc), and return the result any way you like (command line, GUI, website, etc).

0 0
Add a comment Improve this question Transcribed image text
Answer #1

//For any queries, feel free to comment.

The following code is in C++.

Applying formula is:

**CODE**

#include <iostream>
using namespace std;

int main()
{
    double prob_a,prob_b;
    double prob_b_given_a,prob_a_given_b;
  
    //Taking all inputs from the user
    cout<<"Enter probability of A: ";
    cin>>prob_a;
  
    cout<<"Enter probability of B: ";
    cin>>prob_b;
  
    cout<<"Enter probability of B given A: ";
    cin>>prob_b_given_a;
  
    //Applying Bayes' theorem
    prob_a_given_b = prob_b_given_a * prob_a;
    prob_a_given_b /= prob_b;
  
    cout<<"Probability of A given B: "<<prob_a_given_b;
  
    return 0;
}

**SCREENSHOTS**

Add a comment
Know the answer?
Add Answer to:
Using your programming language of choice, write a program that will ask for: Probability of A...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Using the programming language of your choice, write a client application which: Connects to a network...

    Using the programming language of your choice, write a client application which: Connects to a network service, then Asks for version information, then Receives the response, then Disconnects and Prints out the response. Detail: The program will take no input from the user. When your program is executed, it should connect to IP address 64.183.98.170 on port 3800. Upon successful connection, send the string: version\n where \n is an end of line marker. The server will respond with a string...

  • In C Programming Language, write a simple program to read one text file and print to...

    In C Programming Language, write a simple program to read one text file and print to screen all its text. Make use of the stderr and exit program statements should there not be only one text file identified on the command line. If successful then before fclose of the text file, use the fputs program statement to write a line "72 degrees Sunny light wind. Nice!\n". print the return code of fputs (should be zero). close and exit. Test program...

  • Write a java program that demonstrates recursion. This program can be in a java GUI frame...

    Write a java program that demonstrates recursion. This program can be in a java GUI frame or as a console application. On this one it is up to you. (It would probably work better as a console program for this particular program.) The input for this program is a number of boxes. Ask the user for this with a textbox or a prompt on the command line. Demonstrate recursion with a function called LoadTruck() that takes a number of boxes...

  • Using Java programming language Your assignment is to implement a recursive reverse sorting algorithm. It should...

    Using Java programming language Your assignment is to implement a recursive reverse sorting algorithm. It should meet the following requirements: 1. The program shall graphically prompt the user for a file. 2. The program shall read the selected file which will contain 1 integer per line. 3. The program shall sort the values it reads from the file from largest to smallest. 4. The program shall write the values to an output file from largest to smallest in the same...

  • C Language Programming. Using the program below - When executing on the command line only this...

    C Language Programming. Using the program below - When executing on the command line only this program name, the program will accept keyboard input and display such until the user does control+break to exit the program. The new code should within only this case situation “if (argc == 1){ /* no args; copy standard input */” Replace line #20 “filecopy(stdin, stdout);” with new code. Open read a text file “7NoInputFileResponse.txt” that contains a message “There were no arguments on the...

  • It is required to write a Matrix Calculator Program using C Programming Language that could only...

    It is required to write a Matrix Calculator Program using C Programming Language that could only perform addition, subtraction, and multiplication of two matrices of appropriate dimensions. Your program should prompt the user to select a matrix operation from a list of options that contains the aforementioned operations. Then, the user should be prompted to enter the dimensions of the two operand matrices. Next, your program should prompt the user to enter the elements of each matrix row-wise. Your program...

  • using python programming language write a program that will manipulate the below excel record to the...

    using python programming language write a program that will manipulate the below excel record to the output provided This is what the output should look like Name Path ID Python-Excel C:\Users Desktop Python-Excell, C:Users IDesktop|Python-Excel2 PE12370, P009872,CD12890,U199912

  • //I NEED THE PROGRAM IN C LANGUAGE!// QUESTION: I need you to write a program which...

    //I NEED THE PROGRAM IN C LANGUAGE!// QUESTION: I need you to write a program which manipulates text from an input file using the string library. Your program will accept command line arguments for the input and output file names as well as a list of blacklisted words. There are two major features in this programming: 1. Given an input file with text and a list of words, find and replace every use of these blacklisted words with the string...

  • Programming: Write a SPIM assembly language program num-vowel.s based on the hardware implementation method in the...

    Programming: Write a SPIM assembly language program num-vowel.s based on the hardware implementation method in the lab notes and the above practice. The program will do the following: Prompt the user to enter a string. The program will call the procedure vowelp to check if a character entered in the string is a vowel or not. Count how many vowels and how many non-vowels are in the string. Print out the calculated results with appropriate message. Hint: A loop is...

  • Java programming Create a simple tip calculator called TipCalcMethod. Your program should read in the bill...

    Java programming Create a simple tip calculator called TipCalcMethod. Your program should read in the bill amount from the command-line, then show 3 tip amounts: 15%, 20% and 25% of the bill. Don't worry about rounding the result to two decimal places, but make sure that the result includes cents (not just dollars). This program will be different than your first Tipcalc program because you will writea method to calculate the tip amount. program will have 2 methods: main) and...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT