answer.
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
Igoryamba
2 years ago
3

Create a C# Console program named TipCalculationthat includes two overloaded methods named DisplayTipInfo.

Computers and Technology
1 answer:
dimulka [17.4K]2 years ago
7 0

Answer:

The code for the program is given in the explanation

Explanation:

using System;

using static System.Console;

class TipCalculation

{

   //definition of the Main()

   static void Main()

   {      

       double dPrice, dTip;

       int iTip;

       //prompt and accept a meal price and a tip as doubles

       Write("Enter a floating point price of the item : ");

       dPrice = Convert.ToDouble(Console.ReadLine());

       Write("Enter a floating point tip amount: ");

       dTip = Convert.ToDouble(Console.ReadLine());

       //call the method DisplayTipInfo()

       //with doubles

       DisplayTipInfo(dPrice, dTip);

       //prompt and accept a meal price as a double

       //and a tip amount as an integer

       Write("\nEnter a floating point price of another item : ");

       dPrice = Convert.ToDouble(Console.ReadLine());

       Write("Enter a integral tip amount: ");

       iTip = Convert.ToInt32(Console.ReadLine());

       //call the method DisplayTipInfo()

       //with double and an integer

       DisplayTipInfo(dPrice, iTip);

   }

   //definition of the method DisplayTipInfo()

   //accept a meal price and a tip as doubles

   public static void DisplayTipInfo(double price, double tipRate)

   {

       //find the tip amount

       double tipAmount = price * tipRate;

       //find the total amount

       double total = price + tipAmount;

       //print the output

       WriteLine("Meal price: $" + price.ToString("F") + ". Tip percent: " + tipRate.ToString("F"));

       WriteLine("Tip in dollars: $" + tipAmount.ToString("F") + ". Total bill $" +          total.ToString("F"));

   }

   //definition of the method DisplayTipInfo()

   //accept a meal price and a tip as doubles

   //a meal price as a double and a tip amount as an integer

   public static void DisplayTipInfo(double price, int tipInDollars)

   {

       //find the tip rate

       double tipRate = tipInDollars / price;

       //find the total amount

       double total = price + tipInDollars;

       //print the output

       WriteLine("Meal price: $" + price.ToString("F") + ". Tip percent: " +                 tipRate.ToString("F"));

       WriteLine("Tip in dollars: $" + tipInDollars.ToString("F") + ". Total bill $" +               total.ToString("F"));

   }

}

You might be interested in
Three variables , x, y and z, supposedly hold strings of digits, suitable for converting to integers. Write code that converts t
zimovet [89]

Answer:

Check the explanation

Explanation:

x, y, z = "abc", "15", "boo"

errors = []

try:

   x = int(x)

except ValueError:

   errors.append('x')

try:

   y = int(y)

except ValueError:

   errors.append('y')

try:

   z = int(z)

except ValueError:

   errors.append('z')

if len(errors) == 0:

   print(x+y+z)

else:

   print('bad value(s) in: ' + ' '.join(errors))

5 0
2 years ago
Read 2 more answers
Write a program that reads students’ names followed by their test scores. The program should output each student’s name followed
bekas [8.4K]

Answer:

See explaination

Explanation:

#include <iostream>

#include <iomanip>

#include <fstream>

#include <string>

using namespace std;

void readStudentsData();

void levels(int&,int&,int&);

int main()

{

string studentsName[50];

int grade[50];

int highestScore = 0;

int belowAverage = 50;

int countStudents = 0;

int sum = 0;

int score[5]=

double average = 0;

ifstream infile;

ofstream outfile;

void readStudentsData();

infile.open("c:\\Data.txt");

int numOfStudents = 0;

infile >> studentsName[numOfStudents] >> grade[numOfStudents];

While (infile && numOfstudents < 50)

{

numOfStudents++;

infile >> studentsName[numOfStudents] >> grade[numOfStudents};

}

if (!infile)

{

cout << "File does not open." << endl;

return 1;

}

outfile.open("c:\\average.out");

outfile << fixed << showpoint;

outfile << setprecision(2);

infile >> studentsName;

infile >> score1 >> score2 >> score3 >> score4 >> score5 >>;

outfile << left << setw(20) << "Students Name"

<< setw(5) << "Score 1" << setw(5) << "Score 2"

<< setw(5) << "Score 3" << setw(5) << "Score 4"

<< setw(5) << "Score 5" << setw(5) << "Grade"

<< setw(5) << "Average" << setw(5) << "Below average"

<< setw(5) << "Highest" << endl;

if (average >= 90)

cout << "A" << endl;

else if (average >= 80)

cout << "B" << endl;

else if (average >= 70)

cout << "C" << endl;

else if (average >= 60)

cout << "D" << endl;

else

cout << "F" << endl;

}

average = static_cast<double>(score1+score2+score3+score4+score5) /5;

void level(int &highestScore,int &belowAverage,int &sum);

{

int level,high = 0,low = 17;

infile >> level;

while(level!=-1)

{

sum = sum + level;

if (level > high)

{

high = level;

infile >> level;

}

else

if (level < low)

{

low = level;

infile >> level;

}

else

if infile >> level;

}

outfile << ' ' << high;

else

if (high > highestScore)

highestScore=high;

else

if (low < belowAverage)

belowAverage=low;

}

do

{

cout << "Students Name: ";

cin >> name

cout << "Input score: " << endl;

cin >> score1>> score2>> score3>> score4>> score5;

cout << Students Name << Highest score);

}

While (highest score !=0);

infile.close();

outfile.close();

return 0;

}

5 0
2 years ago
9.6 Code Practice: Question 1
worty [1.4K]

Answer:

  1. import java.util.Random;
  2. import java.util.Arrays;
  3. public class Main {
  4.    public static void main(String[] args) {
  5.        int n = 10;
  6.        int [] myArray = new int[n];
  7.        buildArray(myArray, n);
  8.        System.out.println(Arrays.toString(myArray));
  9.    }
  10.    public static void buildArray(int[] arr, int n){
  11.        for(int i=0; i < arr.length; i++){
  12.            Random rand = new Random();
  13.            arr[i] = rand.nextInt(90) +10;
  14.        }
  15.    }
  16. }

Explanation:

Firstly, create a method buildArray that take two inputs, an array and an array size (Line 12). In the method, use random nextInt method to repeatedly generate a two digit random number within a for loop that will loop over array size number of times (Line 13-15). The expression rand.nextInt(90) + 10 will generate digits between 10 - 99.

In the main program, call the build array method by using an array and array size as input arguments (Line 8). At last, print the array after calling the buildArray method (Line 9).

8 0
2 years ago
"There are no longer mature industries; rather, there are mature ways of doing business," he is referring to the high demand of
yanalaym [24]

Hi, you've asked an incomplete and unclear question. However, I provided the full text below.

Explanation:

The text reads;

<em>"When Porter says “There are no longer mature industries; rather, there are mature ways of doing business,” he is referring to the high demand for creativity and innovation in the market. Earlier we used to be more concerned about the hardware and the physical product rather than its information content, But now as a business, we need to provide more informative content with the product.</em>

<em>Like General Electric offers dedicated customer service for its line of goods which differentiates it from its rivals. Similarly, shipping companies like UPS now offer us to track the location of our package on a live map. This is what we call a mature business and how we can differentiate ourselves and stand out in the highly competitive market by using Information and Technology..."</em>

4 0
2 years ago
1.the following code example would print the data type of x, what data type would that be?
natta225 [31]

Answer:

x = 5, the data type is integer( integer data type is for whole numbers)

2. The data type is string

3. The data type is float (float data type is for decimals)

Explanation:

6 0
2 years ago
Other questions:
  • Seneca has just applied conditional formatting and realizes that she has made a mistake. Which action should she take to fix the
    12·1 answer
  • True or False: A class that implements an interface may only implement a few of that interface's method declarations
    13·1 answer
  • The effectiveness of a(n) _____ process is essential to ensure the success of a data warehouse. Select one: a. visual basic b. e
    15·2 answers
  • Write measurable performance objectives.Suppose that a trainer has identified as a generalgoal for a training module,"Able to fo
    13·1 answer
  • Sarah works in a coffee house where she is responsible for keying in customer orders. A customer orders snacks and coffee, but l
    13·2 answers
  • Double any element's value that is less than controlValue. Ex: If controlValue = 10, then dataPoints = {2, 12, 9, 20} becomes {4
    8·2 answers
  • Which option in the Caption dialog box configures whether the caption appears above or below the image
    11·2 answers
  • Which of the following is true about sorting functions?
    14·1 answer
  • You know that you should check the room for security against unwanted entry do you check locks on doors and windows. What else d
    15·1 answer
  • Doug grew up on a large farm in southwest Wisconsin. As a college graduation gift, Doug’s father gave him several hundred acres
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!