C#: I am working on this application and keep running into this error. Please help me fix it.
Error:
![Form 1.cs ผื -p X Form1.csLDesign] ū SinghAjayProgram08 Form1 spinButton_Click(object sender, EventArgse int pictureIhrea - r](http://img.homeworklib.com/images/1c8bb92e-6cc1-431f-8e7a-08a19274142c.png?x-oss-process=image/resize,w_560)
Design:
![Form 1.cs Form1.cs [Design] x Slot Machine Amount Inserted: Spin Exit 囤fruitsimageList](http://img.homeworklib.com/images/1947456e-7ee6-44eb-9a7b-9ca93594aedc.png?x-oss-process=image/resize,w_560)
Code:
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 SinghAjayProgram08
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
double totalInserted = 0;
double totalWon = 0;
private void spinButton_Click(object sender, EventArgs e)
{
Random rand = new Random();
int index = rand.Next(fruitsImageList.Images.Count);
firstPictureBox.Image = fruitsImageList.Images[index];
secondPictureBox.Image = fruitsImageList.Images[index];
thirdPictureBox.Image = fruitsImageList.Images[index];
int pictureOne = rand.Next(0, 10);
int pictureTwo = rand.Next(0, 10);
int pictureThree = rand.Next(0, 10);
double amount = double.Parse(amountTextBox.Text);
totalInserted += amount;
// Picture one
if (pictureOne == 0)
{
firstPictureBox.Image = Image.FromFile("Apple.bmp");
}
else if (pictureOne == 1)
{
firstPictureBox.Image = Image.FromFile("Banana.bmp");
}
else if (pictureOne == 2)
{
firstPictureBox.Image = Image.FromFile("Cherries.bmp");
}
else if (pictureOne == 3)
{
firstPictureBox.Image = Image.FromFile("Grapes.bmp");
}
else if (pictureOne == 4)
{
firstPictureBox.Image = Image.FromFile("Lemon.bmp");
}
else if (pictureOne == 5)
{
firstPictureBox.Image = Image.FromFile("Lime.bmp");
}
else if (pictureOne == 6)
{
firstPictureBox.Image = Image.FromFile("Orange.bmp");
}
else if (pictureOne == 7)
{
firstPictureBox.Image = Image.FromFile("Pear.bmp");
}
else if (pictureOne == 8)
{
firstPictureBox.Image = Image.FromFile("Strawberry.bmp");
}
else if (pictureOne == 9)
{
firstPictureBox.Image = Image.FromFile("Watermelon.bmp");
}
// Picture two
if (pictureTwo == 0)
{
secondPictureBox.Image = Image.FromFile("Apple.bmp");
}
else if (pictureTwo == 1)
{
secondPictureBox.Image = Image.FromFile("Banana.bmp");
}
else if (pictureTwo == 2)
{
secondPictureBox.Image = Image.FromFile("Cherries.bmp");
}
else if (pictureTwo == 3)
{
secondPictureBox.Image = Image.FromFile("Grapes.bmp");
}
else if (pictureTwo == 4)
{
secondPictureBox.Image = Image.FromFile("Lemon.bmp");
}
else if (pictureTwo == 5)
{
secondPictureBox.Image = Image.FromFile("Lime.bmp");
}
else if (pictureTwo == 6)
{
secondPictureBox.Image = Image.FromFile("Orange.bmp");
}
else if (pictureTwo == 7)
{
secondPictureBox.Image = Image.FromFile("Pear.bmp");
}
else if (pictureTwo == 8)
{
secondPictureBox.Image = Image.FromFile("Strawberry.bmp");
}
else if (pictureTwo == 9)
{
secondPictureBox.Image = Image.FromFile("Watermelon.bmp");
}
// Picture three
if (pictureThree == 0)
{
thirdPictureBox.Image = Image.FromFile("Apple.bmp");
}
else if (pictureThree == 1)
{
thirdPictureBox.Image = Image.FromFile("Banana.bmp");
}
else if (pictureThree == 2)
{
thirdPictureBox.Image = Image.FromFile("Cherries.bmp");
}
else if (pictureThree == 3)
{
thirdPictureBox.Image = Image.FromFile("Grapes.bmp");
}
else if (pictureThree == 4)
{
thirdPictureBox.Image = Image.FromFile("Lemon.bmp");
}
else if (pictureThree == 5)
{
thirdPictureBox.Image = Image.FromFile("Lime.bmp");
}
else if (pictureThree == 6)
{
thirdPictureBox.Image = Image.FromFile("Orange.bmp");
}
else if (pictureThree == 7)
{
thirdPictureBox.Image = Image.FromFile("Pear.bmp");
}
else if (pictureThree == 8)
{
thirdPictureBox.Image = Image.FromFile("Strawberry.bmp");
}
else if (pictureThree == 9)
{
thirdPictureBox.Image = Image.FromFile("Watermelon.bmp");
}
if (pictureOne == pictureTwo && pictureOne ==
pictureThree)
{
totalWon += amount * 3;
MessageBox.Show("You Won" + (amount * 3).ToString("c"));
}
else if (pictureOne == pictureTwo || pictureOne ==
pictureThree
|| pictureTwo == pictureThree)
{
totalWon += amount * 2;
MessageBox.Show("You Won" + (amount * 2).ToString("c"));
}
else
{
MessageBox.Show("You Won" + 0.ToString("c"));
}
}
private void exitButton_Click(object sender, EventArgs e)
{
MessageBox.Show("Total Inserted" + " amount is" +
totalInserted.ToString("c")
+ "\nTotal Winning amount is" + totalWon.ToString("c"));
this.Close();
}
}
}
Assignment:

You are getting this error because you are not catching an unchecked expression in your code. The type of Exception is FileNotFoundException, this type of exception happens when the file you are trying to open is not found.
I would first suggest you to first make sure the file you are trying to exits actually exist.
And, moreover you would also need to catch the required exception as shown below.
try {
firstPictureBox.Image = Image.FromFile("Banana.bmp");
} catch(FileNotFoundException e) {
Console.WriteLine("Exception caught: {0}", e);
}
C#: I am working on this application and keep running into this error. Please help me fix it. Err...
C# Temperature Converter Application:
I have most of the application complete I just need only
help with error messages.
My instructor wants me to show four error messages
inside an error message label (not a message box) and all of the
error messages should appear inside error message label. The four
error messages should appear when:
1: User enters data inside both Celsius and fahrenheit
text boxes: “You should enter data in only one textbox. Press Clear
to start over.”...
6-1 Test and debug the Invoice Application
i need help with this please.. all help is appreciated
Source code Java:
import java.util.Scanner;
import java.text.NumberFormat;
public class InvoiceApp {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String choice = "y";
while (!choice.equalsIgnoreCase("n")) {
// get the input from the user
System.out.print("Enter customer type (r/c): ");
String customerType = sc.next();
System.out.print("Enter subtotal: ");
double subtotal = sc.nextDouble();
// get the discount percent
double discountPercent = 0.0;
switch(customerType) {...
My Python file will not work below and I am not sure why, please help me debug! ********************************* Instructions for program: You’ll use these functions to put together a program that does the following: Gives the user sentences to type, until they type DONE and then the test is over. Counts the number of seconds from when the user begins to when the test is over. Counts and reports: The total number of words the user typed, and how many...
This is for a Unix class.
Please help me out.
I am attaching a skeletal code of the program below, it just
needs ti be filled in.
Below is a skeletal code of the program. Fork a child process and then use the
parent for reading and the child for writing. This is
just a way of sending and receiving messages
asynchronously.
/*
*************************************************************
* Utility functions
* **************************************************************
*/
static void
usageError(const char * progName, const char *msg)
{...
could you please help me with this problem, also I
need a little text so I can understand how you solved the
problem?
import java.io.File; import java.util.Scanner; /** *
This program lists the files in a directory specified by * the
user. The user is asked to type in a directory name. * If the name
entered by the user is not a directory, a * message is printed and
the program ends. */ public class DirectoryList { public static...
I need help with my very last assignment of this term
PLEASE!!, and here are the instructions: After reading Chapter Two,
“Keys to Successful IT Governance,” from Roger Kroft and Guy
Scalzi’s book entitled, IT Governance in Hospitals and Health
Systems, please refer to the following assignment instructions
below.
This chapter consists of interviews with executives
identifying mistakes that are made when governing healthcare
information technology (IT). The chapter is broken down into
subheadings listing areas of importance to understand...