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
xeze [42]
3 years ago
6

Write an application that allows a user to select a country from a list box that contains the following seven options. After the

user makes a selection, display the country’s capital city.
Country
Capital Austria
Vienna Canada
Toronto England
London France
Paris Italy
Rome Mexico
Mexico City Spain
Madrid
Computers and Technology
1 answer:
hodyreva [135]3 years ago
6 0

Answer:

Programming Language not stated;

But this application definitely requires a graphical user interface platform (so, I'll use Microsoft Visual C# - Winforms).

Controls to be used are.

1. Form

2. List box

I'll name the Form, Form1 and the list box, listbox1.

Explanation:

The code goes thus;

private void Form1_Load(object sender, System.EventArgs e)

{

//Load country into empty listbox

listbox1.Items.Add("Austria");

listbox1.Items.Add("Canada");

listbox1.Items.Add("England");

listbox1.Items.Add("France");

listbox1.Items.Add("Italy");

listbox1.Items.Add("Mexico");

listbox1.Items.Add("Spain");

}

private void listbox1_SelectedIndexChanged(object sender, System.EventArgs e)

{

//Check if an item is really selected

if(listbox1.SelectedIndex >= 0)

{

//Index 0 represents 1st item that was added to the listbox and that's Austria

if(listbox1.SelectedIndex ==0)

{

MessageBox.Show("Vienna");

}

else if(listbox1.SelectedIndex == 1)

{

MessageBox.Show("Toronto");

}

else if(listbox1.SelectedIndex ==2)

{

MessageBox.Show("London");

}

else if(listbox1.SelectedIndex == 3)

{

MessageBox.Show("Paris");

}

else if(listbox1.SelectedIndex ==4)

{

MessageBox.Show("Rome");

}

else if(listbox1.SelectedIndex == 5)

{

MessageBox.Show("Mexico City");

}

else if(listbox1.SelectedIndex == 6)

{

MessageBox.Show("Madrid");

}

}

else

{

MessageBox.Show("No item selected");

}

}

You might be interested in
(5 points) Create a user-defined data structure (i.e., struct) called Point that represents a two-dimensional Cartesian coordina
Harlamova29_29 [7]

Answer:

Here is the C++ program:

#include<iostream>  //to use input output functions

#include <math.h>  //to use sqrt and pow function

#include<iomanip>  //to use setprecision

using namespace std;   //to identify objects cin cout

struct Point  {  // structure name

float x,y;  // member variables

};  

float calculateDistance (Point a, Point b)  {  //function that that takes two parameters of type Point

float distance;  //stores the distance between two points

distance=sqrt(pow(a.x-b.x,2)+pow(a.y-b.y,2));  //formula to compute distance between two points

return distance;  }  //returns the computed distance

int main()  {  //start of main function

Point p1,p2;  //creates objects of Point

cout<<"Enter point 1 coordinates: "<<endl;  //prompts user to enter the value for coordinates of first point

cin>>p1.x;  //reads input value of x coordinate of point 1 (p1)

cin>>p1.y;  //reads y coordinate of point 1 (p1)

cout<<"Enter point 2 coordinates: "<<endl;  //prompts user to enter the value for coordinates of second point

cin>>p2.x;  //reads input value of x coordinate of point 2 (p2)

cin>>p2.y;  //reads y coordinate of point 2 (p2)

cout<<"The distance between two points is "<<fixed<<setprecision(2)<<calculateDistance(p1,p2);} //calls function by passing p1 and p2 to compute the distance between p1 and p2 and display the result (distance) up to 2 decimal places

Explanation:

The program has a structure named Point that represents a two-dimensional Cartesian coordinate (x, y). The member variables of this struct are x and y, which are both floating-point values. A function called calculateDistance takes two parameters, a and b of type Pointer and returns the distance between the two given points using formula:

\sqrt{(x_{2}-x_{1} )^{2} +(y_{2}-y_{1} )^{2}  }

It uses pow function to compute the power of 2 and sqrt function to compute the square root.

Then in main() method the program prompts the user to enter coordinates for two points and calls calculateDistance method to compute the distance between two points and display the result up to 2 decimal places using setprecision(2).

The program along with the output is attached in a screenshot.

6 0
2 years ago
A virus is a self-replicating program that produces its own code by attaching copies of it into other executable codes.
Allisa [31]

Answer: Stealth/Tunneling Virus

Explanation: Stealth or tunneling virus are the virus which are responsible for attacking a computer system which causes the problem in the functioning of the operating system by manipulating files, creating partition etc.

These viruses try to avoid or prevent the anti-virus scans for the detection any sort of virus or error . They act to prevent any malfunction detection by taking charge for the anti-virus operation.

5 0
3 years ago
What is the function for displaying differences between two or more scenarios side by side?
deff fn [24]

Answer:

its d

Explanation:

3 0
3 years ago
Read 2 more answers
A USB zipper drive is a small data storage device that plugs into a computer's USB port.
choli [55]
<span>A. True. hope this is what u are looking for</span>
5 0
3 years ago
Uses computers resources from multiple locations to solve ​
kodGreya [7K]

Answer:

computers are solve all things in are life

3 0
3 years ago
Read 2 more answers
Other questions:
  • would specify that only selected members of the payroll and human resources department would have the right to change sensitive
    11·1 answer
  • How does microchip work
    12·1 answer
  • .When an argument is passed ______________, the called method can access and modify the caller’s original data directly.
    8·1 answer
  • Discuss anomaly detection.
    5·1 answer
  • 1. Consider a direct-mapped cache that can accommodate 8Mbytes from a main memory, that uses a 32-bit address and 32-byte blocks
    5·1 answer
  • Design the following webpage using suitable html code .
    11·2 answers
  • Which data type can store decimal or fractional numbers?
    15·2 answers
  • Please help with question
    14·1 answer
  • Which two peripherals are not required to browse the internet?
    8·1 answer
  • We call any device connected to the Internet a(n) ________. Group of answer choices router host IP client
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!