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
vekshin1
3 years ago
15

Write a program that reads two fractions such as 1/2 and 1/4 and computes and stores the sum, the difference, the product and th

e result of dividing one by the other in four other fractions, respectively. Display the four resulting fractions. The following is a sample interaction between the user and the program: Enter two fractions: 1/2 1/4 Sum fraction: 6/8 Difference: 2/8 Product: 1/8 Quotient: 4/2 Press any key to continue. If n1/d1 and n2/d2 are the two fractions, their sum is given by: n1d2+ n2d1/d1d2 their difference is given by: n1d2-n2* d1/d1d2 Product is: n1n2/d1d2 Quotient: nl. d2/d1n2 Make sure the program pauses and waits for a key to be pressed before continuing. Put your name on top as a comment. Use comments to explain where your code may not be clear enough. After building and testing the program, submit the cpp file. There are two steps in submitting an assignment: first click Choose File and once you locate the file, click Upload to upload it. Once you have uploaded the file click Finish to submit. It will not be submitted until you click Finish. Make sure not to click Finish before uploading the files, as it will send a blank page and you can't resubmit. Each student must write his or her own program.
Computers and Technology
1 answer:
Vesnalui [34]3 years ago
5 0

Answer:

1: #include <iostream>

2: using namespace std;

3: int main()

4: {

5: int a,b,c,d;

6: cout<<"n1: ";

7: cin>>a;

8: cout<<"d1: ";

9: cin>>b;

10: cout<<"n2: ";

11: cin>>c;

12: cout<<"d2: ";

13: cin>>d;

14: int top = (a*d)+(b*c);

15: int bottom = b*d;

16: cout<<"Sum: "<<top<<"/"<<bottom<<"\n";

17: top = (a*d)-(b*c);

18: cout<<"Difference: "<<top<<"/"<<bottom<<"\n";

19: top = a*c;

20: cout<<"Product: "<<top<<"/"<<bottom<<"\n";

21: top = a*d;

22: bottom = b*c;

23: cout<<"Quotient: "<<top<<"/"<<bottom<<"\n";

24: return 0;

25: }

Explanation:

The Program is written in C++ programming language

The Program is left numbered

Line 5 was used for variable declaration.

Variables a,b represents the numerator and denominator of the first fraction

While variables c,d represent the numerator and denominator of the second fraction

Line 6 prints "n1" without the quotes which represents the numerator of the first fraction

Line 7 accepts input for the numerator of the first fraction.

Line 8 prints "d1" without the quotes which represents the denominator of the first fraction

Line 9 accepts input for the denominator of the first fraction.

Line 10 prints "n2" without the quotes which represents the numerator of the second fraction

Line 11 accepts input for the numerator of the second fraction.

Line 12 prints "d2" without the quotes which represents the denominator of the second fraction

Line 13 accepts input for the denominator of the second fraction.

Line 14 and 15 calculate the sum of the fractions which is then printed on line 16

Line 17 calculates the difference of the fractions which is then printed on line 18

Line 19 calculates the product of the fractions which is then printed on line 20

Line 21 and 22 calculates the quotient of the fractions which is then printed on line 23

You might be interested in
You will write a program that reads a binary file that contains records of creatures. Each record can be stored in a Creature st
yuradex [85]

Answer:

Explanation:

main.cpp file

/******************************

Name

Date

PA1_Starter.cpp

Description

********************************/

// Headers

#include <iostream>

#include <cstdlib>

#include <string>

#include <vector>

#include <fstream>

#include <algorithm>

using namespace std;

// Global variables

const int CREATURE_NAME_SIZE = 30; // Max length of a creature name

const int CREATURE_TYPE_SIZE = 26; // Max length of a creature type

const string FILENAME = "creatures.dat"; // Name of file that contains the data

// struct used to create records in file

struct Creature

{

char name[CREATURE_NAME_SIZE]; // Name of the creature

char creatureType[CREATURE_TYPE_SIZE]; // Type of creature

int hp; // Hit points for creature

int armor; // Armor class for creature

int speed; // Speed of creature

};

// This function returns true if the name of the left creature is less than the name of the right creature

// Use this function when running the sort function

bool sortByName(const Creature &lhs, const Creature &rhs)

{

string name1(lhs.name), name2(rhs.name);

return name1 < name2;

}

// Function declarations

// You will need to code the definitions for each of these functions

int getCreatureNumber(int numCreatures);

void displayCreature(fstream& file, int num);

void displaySorted(fstream& file);

int main()

{

char choice; // choice made by user for menu

fstream creatureFile; // file stream for input file

int numCreatures; // the number of creatures saved to the file

 

// Open the creatureFile for input and binary (one statement of code)

 

// Get the number of creatures in the file (two statements of code)

// The number of creatures should be assigned to numCreatures

do

{

cout << "Menu" << endl;

cout << "1. Display a specific creature\n";

cout << "2. Display all creatures sorted by name\n";

cout << "3. Quit\n";

cout << "Enter your choice (1, 2, 3): ";

cin >> choice;

while (cin.get() != '\n');

switch (choice)

{

case '1': // Display a specific creature

displayCreature(creatureFile, getCreatureNumber(numCreatures));

break;

case '2': // Display all the creatures in order

displaySorted(creatureFile);

break;

case '3': // Quit

break;

default:

cout << "Invalid option.\n";

break;

}

if (choice != '3')

{

system("PAUSE");

system("CLS");

}

} while (choice != '3');

creatureFile.close();

 

 

// Make sure we place the end message on a new line

cout << endl;

// The following is system dependent. It will only work on Windows

system("PAUSE");

/*

// A non-system dependent method is below

cout << "Press any key to continue";

cin.get();

*/

return 0;

}

/*******************************************************************

getCreatureNumber gets and returns the record number from the file that the user would like to be displayed

PARAM: numCreatures should be the value of the total number of records (creatures) in the file

PRE: numCreatures contains a value that is equal to the number of records in the file

POST: A value between 1 and numCreatures is returned as selected by the user

NOTE: Do not allow a value less than 1 or greater than numCreatures to be returned

********************************************************************/

int getCreatureNumber(int numCreatures)

{

 

}

/*******************************************************************

displayCreature displays record number num from file

PARAM: file is a fstream that should be open for input and binary

num contains the record number that is to be read in file

PRE: file is a fstream that is open for input and binary

num is a value between 1 and the number of records in file

POST: The record number num is displayed to the monitor

********************************************************************/

void displayCreature(fstream& file, int num)

{

 

}

/*******************************************************************

displaySorted should read file into a vector. It should then sort the vector by

the name of the creature. Last it should display the vector

PARAM: file is a fstream that should be open for input and binary

PRE: file is open for input and binary

POST: Each record is displayed sorted by the name of the creature

********************************************************************/

void displaySorted(fstream& file)

{

 

}

5 0
3 years ago
In today's digital world, companies have created software that makes business communication and productivity more efficient and
Svetach [21]

Answer:

Business communications tools are widely used and the world is becoming increasingly digital so not having those skills will hinder you.

Explanation:

Many jobs require knowledge of Microsoft tools as a qualification. By not having that expertise, I will be viewed as less qualified for a position and may be passed up for job. In corporate America, presentations are a staple and Microsoft PowerPoint is the primary software. If I deliver a poor presentation due to inexperience, I will make myself look bad and as a result get a bad quarterly review and possibly stunted any future promotions. On the flipside, as a business owner Excel is a handy tool for tracking expenses. Very customizable, quick and easy to understand.

7 0
3 years ago
Use the Internet and other sources to research the two disadvantages of standard biometrics: cost and error rates. Select one st
lyudmila [28]

Answer:

Check the explanation

Explanation:

Selecting the bio-metric technique fingerprint, it requires a scanner to read the fingerprint The cost for a scanner is in between 1000 and 5000 Placing two scanners at two entrance of office win cost bellow 10,000 So the cost needed for this technique is medium as compared with other bio-metric techniques

Attacks on this technique can be in saner, channel from scanner to feature extractor, in feature extractor, way in between feature extractor and marcher, in marcher, in database etc this attacks can be protect by using security methods such as cryptography, hashing, watermarking, noses etc

By using watermarking, cryptography and stenography methods, fingerprint has less false detection rate I e it gives high accuracy

I recommend fingerprint technique. Because of it is a standard technique, it has good accuracy and cost is less, and easy to handle, and it is taking small storage space in database.

Kindly check the attached image below.

7 0
3 years ago
Messing around is driven by the user's:
Leni [432]

Answer:

The answer is C

Explanation:

I hope that the answer

8 0
3 years ago
ABC inc. has built a large, normalized, relational database to capture current/historical data originating /copied from its tran
kow [346]

Answer:

"Datawarehouse" is the correct answer for the above question.

Explanation:

  • The Datawarehouse is a collection of large data or database which holds the historical data and the current or operation data for future decisions of the profit of the organization.
  • The decision can be made after being analyzed the data which is extracted from the Dataware house.
  • The above question also states the database which works like the above-defined concept. Hence Datawarehouse is the correct answer to the above question.
6 0
4 years ago
Other questions:
  • Write a program in C which will open a text file named Story.txt. You can create the file using any text editor like notepad etc
    9·1 answer
  • Which spereadsheet type will determine<br> how well a bussiness has done over the past year
    11·1 answer
  • A group of researchers is designing an experiment to test whether meditation helps people fall asleep faster. The researchers se
    14·1 answer
  • What is the difference between requirements and controls in the security process? Give examples of each.
    11·1 answer
  • Within a major students can choose to study a specific area within major. For example a journalism student may study military jo
    8·1 answer
  • How many invalid code sequences can we have in 5b/6b encoding?
    15·1 answer
  • 5
    15·2 answers
  • Before a new email application could be released to the public, it was released for a few days to some account holders of a webs
    14·2 answers
  • Brainliest
    7·1 answer
  • 20 ponts!!!dorothy has made a website for her hair salon on a wysiwyg editor. she wants her website to appear on the first page
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!