Question

Here is my skeleton code to this C# assignement I need to add a few things,...

Here is my skeleton code to this C# assignement I need to add a few things,

  • Change the the switch to If and Else-If statements (and test it is still working here)
  • Add a third "Submit" button called SubmitButton
    • In your If and Else-If add a condition if city is Honolulu and SubmitButton is checked.
    • Display "Honolulu is the best place to be this time of year! I wish I was there!".
  • Add comments, including header.

HELP PLEASE ASAP

public partial class TimeZoneApp : Form
{
public TimeZoneApp()
{
InitializeComponent();
}

private void btnOk_Click(object sender, EventArgs e)
{
string city; // To hold the name of a city

if (cityListBox.SelectedIndex != −1)
{
  
city = cityListBox.SelectedItem.ToString();

switch (city)
{
case "Honolulu":
lblTimeZone.Text = "Hawaii-Aleutian";
break;
case "San Francisco":
lblTimeZone.Text = "Pacific";
break;
case "Denver":
lblTimeZone.Text = "Mountain";
break;
case "Minneapolis":
lblTimeZone.Text = "Central";
break;
case "New York":
lblTimeZone.Text = "Eastern";
break;
}

}
else{
MessageBox.Show("PLease select a valid city.");
}
  
}
}
}

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

Here is code:

private void btnOk2_Click(object sender, EventArgs e)

{

string city; // To hold the name of a city

if (cityListBox.SelectedIndex != −1)

{

city = cityListBox.SelectedItem.ToString();

if (city.Compare(("Honolulu" ) = 0)

{

lblTimeZone.Text = "Hawaii-Aleutian";

}

else if (city.Compare(("San Francisco") = 0){

lblTimeZone.Text = "Pacific";

}

else if (city.Compare(("Denver") = 0){

lblTimeZone.Text = "Mountain";

}

else if (city.Compare(("Minneapolis") = 0){

lblTimeZone.Text = "Central";

}

else if (city.Compare(("New York") = 0){

lblTimeZone.Text = "Eastern";

}

}

else{

MessageBox.Show("PLease select a valid city.");

}

}

Add a comment
Know the answer?
Add Answer to:
Here is my skeleton code to this C# assignement I need to add a few things,...
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
  • How can I add this function to my C# code?: Validate that if the user clicks...

    How can I add this function to my C# code?: Validate that if the user clicks the “OK” button, a “Seating Category” is selected, and at least one ticket is being purchased. If not, pop-up a dialog box asking the user to enter the needed data for the transaction. What we want to avoid is depicted in See Figure 3. Figure 3: This code asks for a seating category to be selected, how many tickets to be purchased, and if...

  • Looking for some help here: Edit GetPhoneData to add more input validation by setting ranges for...

    Looking for some help here: Edit GetPhoneData to add more input validation by setting ranges for values Brands (Samsung, iPhone, Google) Models (Galaxy, Note, 8, X, Pixel) Price ($0.01-$2000) Include a comment about your addition, you can be creative, add components (or not), individualize this. Extra Credit (Samsung must be paired to Galaxy or Note) 2 points Below is the code: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace Cell_Phone_Test {...

  • Hi everyone, For my Assignment I have to use C# in order to create a validation...

    Hi everyone, For my Assignment I have to use C# in order to create a validation form and include the following things to register and validate: Email Address, Username, Password, Retype Password, and a Submit Button. I have figured out some of the code for the Email Address validation: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace Validation4 {     public partial class Form1 : Form     {        ...

  • C# Windows Form Application (CALCULATOR): (This is the instruction below): Windows Calculator that will going to...

    C# Windows Form Application (CALCULATOR): (This is the instruction below): Windows Calculator that will going to create a Windows Form Application that will mimics a calculator. This is the screenshot how it shouldl look like. Calculator It should have a textbox and the following buttons: + Addition - Subtraction * Multiplication / Division = Equals (Will perform the final calculation) C Clear (Will clear the text box) There will be no maximize or minimize buttons. The rules are these: 2...

  • THIS IS MY CODE ALL I NEED IS THE SECTIONS TO BE FILLED IN AND CODE...

    THIS IS MY CODE ALL I NEED IS THE SECTIONS TO BE FILLED IN AND CODE SHOULD RUN. FILL IN THE CODE PLEASE. package p02; import static java.lang.System.*; import java.io.*; import java.util.*; public class P02 {    public static Vector<Double> wallet=new Vector<Double>();    public static void addMoneyToWallet(){    }    public static void removeMoneyFromWallet(){    }    public static void displayMoneyInWallet(){    }    public static void emptyWallet(){    }    public static void main(String[] args){ int choice=0; String menu="Wallet...

  • Can I get some help with this question for c++ if you can add some comments...

    Can I get some help with this question for c++ if you can add some comments too to help understand that will be much appreciated. Code: #include <cstdlib> #include <getopt.h> #include <iostream> #include <string> using namespace std; static long comparisons = 0; static long swaps = 0; void swap(int *a, int *b) {     // add code here } void selectionSort(int *first, int *last) {     // add code here } void insertionSort(int *first, int *last) {     // add code here }...

  • I need help in my C++ code regarding outputting the enums in string chars. I created...

    I need help in my C++ code regarding outputting the enums in string chars. I created a switch statement for the enums in order to output words instead of their respective enumerated values, but an error came up regarding a "cout" operator on my "Type of Item" line in my ranged-based for loop near the bottom of the code. I tried casting "i.type" to both "i.GroceryItem::Section::type" and "i.Section::type", but neither worked. Simply put, if a user inputs 1 as their...

  • how to add methods into thjs code using C# on visual studio? -validatetextbox should return a true false depending if input is valid -resetinput should clear all input and restart radiobuttons...

    how to add methods into thjs code using C# on visual studio? -validatetextbox should return a true false depending if input is valid -resetinput should clear all input and restart radiobuttons to the defult positions -displaymessge must display messge box to the user displaying such as “5+8=12” calculator.cs x Prearam S Miscellaneous Files ator.Designer.c s Calculato 1 曰using Systemi 2 using System.Collections.Generic; using System.ComponentModel; 4 using System.Data; s using System.Drawing; 6 using System.Linq 7using System.Text; 8 using System.Threading.Tasks; 9 using...

  • Java Assignment Calculator with methods. My code appears below what I need to correct. What I...

    Java Assignment Calculator with methods. My code appears below what I need to correct. What I need to correct is if the user attempts to divide a number by 0, the divide() method is supposed to return Double.NaN, but your divide() method doesn't do this. Instead it does this:     public static double divide(double operand1, double operand2) {         return operand1 / operand2;     } The random method is supposed to return a double within a lower limit and...

  • I need to add a method high school student, I couldn't connect high school student to...

    I need to add a method high school student, I couldn't connect high school student to student please help!!! package chapter.pkg9; import java.util.ArrayList; import java.util.Scanner; public class Main { public static Student student; public static ArrayList<Student> students; public static HighSchoolStudent highStudent; public static void main(String[] args) { int choice; Scanner scanner = new Scanner(System.in); students = new ArrayList<>(); while (true) { displayMenu(); choice = scanner.nextInt(); switch (choice) { case 1: addCollegeStudent(); break; case 2: addHighSchoolStudent(); case 3: deleteStudent(); break; case...

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