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
kipiarov [429]
4 years ago
14

Create a program named Auction that allows a user to enter an amount bid on an online auction item. Include three overloaded met

hods that accept an int, double, or string bid. Each method should display the bid and indicate whether it is over the minimum acceptable bid of $10. If the bid is greater than $10, display Bid accepted. If the bid is less than $10, display Bid not high enough. If the bid is a string, accept it only if one of the following is true: It is numeric and preceded with a dollar sign. It is numeric and followed by the word dollars. Otherwise, display a message that says Bid was not in correct format.
Computers and Technology
1 answer:
Natasha_Volkova [10]4 years ago
4 0

Answer:

Code implemented on C# below

Explanation:

using System;

using static System.Console;

using System.Text.RegularExpressions;

public class Auction

{

 

static void Main()

{

int intbid;

//declare min bid value

int min=10;

 

 

//scan input and conver to int

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

AcceptBid(intbid,min);

 

 

double doublebid;

//scan input and conver to double

doublebid=Double.Parse(Console.ReadLine());

AcceptBid(doublebid,min);

 

string stringbid;

//scan string

stringbid=Console.ReadLine();

AcceptBid(stringbid,min);

 

}

 

public static void AcceptBid(int bid, int min)

{

if(bid<min)

Console.WriteLine("Bid not high enough");

else

Console.WriteLine("Bid accepted");

 

}

public static void AcceptBid(double bid, int min)

{

if(bid<min)

Console.WriteLine("Bid not high enough");

else

Console.WriteLine("Bid accepted");

}

public static void AcceptBid(string bid, int min)

{

//using regular expression check if string is starting with $ and rest all are numbers

if(bid[0]=='$'&&Regex.IsMatch(bid.Substring(1,bid.Length-1), @"^d+$")){

//if input string is in required pattern convert string to int and check for min

if(Convert.ToInt32(bid.Substring(1,bid.Length-1))<min)

Console.WriteLine("Bid not high enough");

else

Console.WriteLine("Bid accepted");

 

}

else{

 

 

string[] temp= bid.Split(' '); //will split with ' '

 

if(Regex.IsMatch(temp[0].ToString(), @"^d+$")&&Regex.IsMatch(temp[1].ToString(),"dollars")){

 

//if input string is in required pattern convert string to int and check for min

if(Convert.ToInt32(temp[0].ToString())<min)

Console.WriteLine("Bid not high enough");

else

Console.WriteLine("Bid accepted");

 

}

 

}

}

}

You might be interested in
Create a class that acts as a doubly linked list node. it should contain all the required data fields, at least 1 constructor, a
Zielflug [23.3K]

it is in Microsoft access


8 0
4 years ago
Which file types have .exe and .png as their extensions?
cricket20 [7]
EXE files are executable files.
PNG files are picture files like JPEG etc.
7 0
4 years ago
What is the largest place value in a 12 bit binary number?
azamat
The largest binary number that can be expressed with 12 bits is all 1s, which means 1 followed by 1 followed by 1, up to 12 times.
6 0
3 years ago
Why should one avoid noise in the computer room​
iragen [17]
Is this a joke bc if so why?
5 0
3 years ago
Read 2 more answers
A researcher wants to do a web-based survey of college students to collect information about their sexual behavior and drug use.
finlep [7]

The answer is already given at the end of the question; solely by the magnitude or severity of expected harm

When assessing risks of harm associated with participation in a research study, the probability of harm and the risk of the severity of harm are two distinctive elements of risk that must be considered. In probability of harm, the fact that not all possible harms are equally probable should be considered. How these two elements occur is a crucial factor in determining the level of risk of harm in a study. Given the sensitivity of the information in the case scenario above, the probability that an individual subject could be identified is low while the magnitude of the possible risk of harm is high.


5 0
4 years ago
Read 2 more answers
Other questions:
  • What is the advantage of defining a target user?
    14·1 answer
  • The salespeople at hyperactive media sales all use laptop computers so they can have easy access to important data on the road.
    9·1 answer
  • ________ feature full-time monitoring tools placed at the most vulnerable points, or "hot spots", of corporate networks to prote
    10·1 answer
  • Ashton Auto Place is a car dealer for new as well as used cars of all makes. It uses computerized Transaction Processing System
    7·1 answer
  • Describing Editing Task
    6·1 answer
  • Ecommerce sites sell this to generate income
    11·1 answer
  • The double equal sign (==) is used to compare values. <br>true or false​
    14·1 answer
  • How would you compare and contrast the impact of the printing press with the impact of the internet?
    15·1 answer
  • ¿Cuál es la función de un engranaje?
    12·1 answer
  • I will give brainliest !!
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!