Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
U

User 10694570

@User 10694570
About
Posts
25
Topics
16
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Code Help!
    U User 10694570

    I have several issues that I cannot figure out. I need to figure out how to ensure that all data is saved in the database. I also need to figure out how to display an order summary and order list. Any pointers in the right directions are appreciated.

    import java.awt.GridLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.ButtonGroup;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JOptionPane;
    import javax.swing.JPanel;
    import javax.swing.JRadioButton;
    import javax.swing.JTabbedPane;
    import javax.swing.JTextArea;
    import javax.swing.JTextField;
    import javax.swing.SwingConstants;

    public class Flooring extends JFrame implements ActionListener{
    JRadioButton radioWood, radioCarpet, radioGroup;
    JLabel labelName, labelAddress, labelLength, labelWidth;
    JTextField textName, textAddress, textLength, textWidth, textCalculateArea;
    JButton buttonCalculateArea, buttonCalculateCost, buttonSubmitOrder, buttonDisplaySummary, buttonDisplayList;
    JTextArea textAreaSummary;
    JTabbedPane tabbedPane;

    public Flooring() {

    	super("Flooring");
    		 
    	tabbedPane = new JTabbedPane();
    	
    	//Create Customer Panel & Add To JTabbedPane
    	JPanel panel1 = new JPanel(new GridLayout(5, 2, 4, 9));
    	
    	labelName = new JLabel("Name: ", SwingConstants.CENTER);
    	panel1.add(labelName);
    	textName = new JTextField(10);
    	panel1.add(textName);
    	
    	labelAddress = new JLabel("Address: ", SwingConstants.CENTER);
    	panel1.add(labelAddress);
    	textAddress = new JTextField(50);
    	panel1.add(textAddress);
    
    	tabbedPane.addTab("Customer", null, panel1, "First Panel");
    	
    	//Create Size Panel & Add To JTabbedPane
    	JPanel panel2 = new JPanel(new GridLayout(5, 2, 4, 9));
    	
    	radioWood = new JRadioButton("Wood");
    	radioWood.setBounds(336, 157, 64, 23);
    	radioWood.setSelected(false);
    	panel2.add(radioWood);
    	
    	radioCarpet = new JRadioButton("Carpet");
    	radioCarpet.setBounds(336, 157, 64, 23);
    	radioCarpet.setSelected(false);
    	panel2.add(radioCarpet);
    	
    	labelLength = new JLabel("Flooring Length: ", SwingConstants.CENTER);
    	panel2.add(labelLength);
    	textLength = new JTextField(10);
    	panel2.add(textLength);
    	
    	labelWidth = new JLabel("Flooring Width: ", SwingConstants.CENTER);
    	panel2.add(labelWidth);
    	textWidth = new JTextField(10);
    	panel2.add(textWidth);
    	
    	buttonCalculateArea = new JButton("Calculate Area");
    	panel2.add(buttonCalculateArea);
    
    Java java database sales help tutorial

  • How To Calculate Area
    U User 10694570

    Can anyone aide me if figuring out how to code for calculating area? I know that I need to the length and width the input, convert them to the proper datatype, do the calculations, and display them. I just can't figure out HOW.

    import java.awt.GridLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.ButtonGroup;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JOptionPane;
    import javax.swing.JPanel;
    import javax.swing.JRadioButton;
    import javax.swing.JTabbedPane;
    import javax.swing.JTextArea;
    import javax.swing.JTextField;
    import javax.swing.SwingConstants;

    public class Flooring extends JFrame implements ActionListener{
    JRadioButton radioWood, radioCarpet, radioGroup;
    JLabel labelName, labelAddress, labelLength, labelWidth;
    JTextField textName, textAddress, textLength, textWidth, textCalculateArea;
    JButton buttonCalculateArea, buttonCalculateCost, buttonSubmitOrder, buttonDisplaySummary, buttonDisplayList;
    int area;

    public Flooring() {

    	super("Flooring");
    		 
    	JTabbedPane tabbedPane = new JTabbedPane();
    	
    	//Create Customer Panel & Add To JTabbedPane
    	JPanel panel1 = new JPanel(new GridLayout(5, 2, 4, 9));
    	
    	labelName = new JLabel("Name: ", SwingConstants.CENTER);
    	panel1.add(labelName);
    	textName = new JTextField(10);
    	panel1.add(textName);
    	
    	labelAddress = new JLabel("Address: ", SwingConstants.CENTER);
    	panel1.add(labelAddress);
    	textAddress = new JTextField(50);
    	panel1.add(textAddress);
    
    	tabbedPane.addTab("Customer", null, panel1, "First Panel");
    	
    	//Create Size Panel & Add To JTabbedPane
    	JPanel panel2 = new JPanel(new GridLayout(5, 2, 4, 9));
    	
    	radioWood = new JRadioButton("Wood");
    	radioWood.setBounds(336, 157, 64, 23);
    	radioWood.setSelected(false);
    	panel2.add(radioWood);
    	
    	radioCarpet = new JRadioButton("Carpet");
    	radioCarpet.setBounds(336, 157, 64, 23);
    	radioCarpet.setSelected(false);
    	panel2.add(radioCarpet);
    	
    	labelLength = new JLabel("Flooring Length: ", SwingConstants.CENTER);
    	panel2.add(labelLength);
    	textLength = new JTextField(10);
    	panel2.add(textLength);
    	
    	labelWidth = new JLabel("Flooring Width: ", SwingConstants.CENTER);
    	panel2.add(labelWidth);
    	textWidth = new JTextField(10);
    	panel2.add(textWidth);
    	
    	buttonCalculateArea = new JButton("Calculate Area");
    	panel2.add(buttonCalculateArea);
    	buttonCalculateArea.addActionListener(this);
    
    Java java sales tutorial question

  • Delimiters
    U User 10694570

    How do I separate my input with a tokenizer and delimiter?

    import java.io.BufferedWriter;
    import java.io.FileWriter;

    import javax.swing.JFrame;
    import javax.swing.JPanel;

    /*******************************************************************************************
    Program Name: ClientInformation.java
    Programmer's Name: Elizabeth Conklin
    Program Description: This program will accept user input and save the input to a file.
    *******************************************************************************************/
    public class WClientTest {

    public static void main(String\[\] args) {
    
    	WClient myWClient = new WClient();
    	myWClient.setDefaultCloseOperation(JFrame.EXIT\_ON\_CLOSE);
    	myWClient.setSize(650, 175);
    	myWClient.setTitle("Client Information");
    	myWClient.setVisible(true);	
    }
    

    }

    import java.awt.*;
    import java.awt.event.*;

    import javax.swing.*;

    import java.io.*;
    import java.util.ArrayList;
    import java.util.StringTokenizer;

    public class WClient extends JFrame {

    JLabel labelName;
    JLabel labelID;
    JLabel labelStartingBalance;
    JLabel labelClosingBalance;
    JTextField textName;
    JTextField textID;
    JTextField textStartingBalance;
    JTextField textClosingBalance;
    JButton buttonSave;
    
    public WClient() {
    	setLayout(new GridLayout(0,4));
    
    	labelName = new JLabel("Client Name: ");
    	add(labelName);
    	textName = new JTextField(10);
    	add(textName);
    	labelID = new JLabel("Client ID: ");
    	add(labelID);
    	textID = new JTextField(10);
    	add(textID);
    	labelStartingBalance = new JLabel("Starting Balance: ");
    	add(labelStartingBalance);
    	textStartingBalance = new JTextField(10);
    	add(textStartingBalance);
    	labelClosingBalance = new JLabel("Closing Balance: ");
    	add(labelClosingBalance);
    	textClosingBalance = new JTextField(10);
    	add(textClosingBalance);
    	buttonSave = new JButton("SAVE");
    	add(buttonSave);
    
    	event e = new event();
    	buttonSave.addActionListener(e);}
    
    public class event implements ActionListener{
    	public void actionPerformed(ActionEvent e) {
    			try {
    				String name = textName.getText();
    				String ID = textID.getText();
    				String startingBalance = textStartingBalance.getText();
    				String closingBalance = textClosingBalance.getText();
    				
    				textName.setText("");
    				textID.setText("");
    				textStartingBalance.setText("");
    				textClosingBalance.setText("");
    				
    				BufferedWriter outfile = new BufferedWriter(new FileWriter("client.txt", true));
    				
    				outfile
    
    Java question java

  • Java Application Help - Inner Class?
    U User 10694570

    My program this week is to create an application that will calculate services (oil change, car wash, or both) provided to customers. The services should be totaled and a message box should display the services rendered and the total sales amount for the purchase. Also, the client should be able to clear the application for a new user. For whatever reason, this inner class is confusing me, and I'm not sure that I'm even on the right track. Any help would be greatly appreciated.

    import javax.swing.JFrame;

    public class CarCareTest {

    public static void main(String\[\] args) {
    
        CarCare myCarCare = new CarCare();
        myCarCare.setSize(500, 500);
        myCarCare.setVisible(true);
        myCarCare.setDefaultCloseOperation(JFrame.EXIT\_ON\_CLOSE);
    
    }
    

    }

    import javax.swing.JFrame;
    import javax.swing.JMenu;
    import javax.swing.JMenuItem;
    import javax.swing.JMenuBar;
    import javax.swing.JOptionPane;
    import java.awt.Color;
    import java.awt.FlowLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.WindowEvent;

    public class CarCare extends JFrame {

    //Declare Class Variables
    private JMenuItem bronzeOil, silverOil, goldOil;
    private JMenuItem basicWash, betterWash, bestWash;
    private JMenuItem total, clear, exit;
    private int priceOilChange, priceCarWash;
    
    //Create Constructor
    public CarCare(){
    	super("Quick Fast Car Care");
    
    	//Instantiate Top Level Menu Items
    	JMenu oilchangeMenu = new JMenu ("Oil Change");
    	JMenu carwashMenu = new JMenu ("Car Wash");
    	JMenu totalclearexitMenu = new  JMenu ("Total/Clear/Exit");
    	
    	//Instantiate Sub Menu Items
    	bronzeOil = new JMenuItem("Bronze");
    	silverOil = new JMenuItem("Silver");
    	goldOil = new JMenuItem("Gold");
    	basicWash = new JMenuItem("Basic");
    	betterWash = new JMenuItem("Better");
    	bestWash = new JMenuItem("Best");
    	total = new JMenuItem("Total");
    	clear = new JMenuItem("Clear");
    	exit = new JMenuItem("Exit");
    	
    	//Set Layout Manager
    	setLayout(new FlowLayout());
    	
    	//Add Sub Menu Items To Top Level Menu
    	oilchangeMenu.add(bronzeOil);
    	oilchangeMenu.add(silverOil);
    	oilchangeMenu.add(goldOil);
    	carwashMenu.add(basicWash);
    	carwashMenu.add(betterWash);
    	carwashMenu.add(bestWash);
    	totalclearexitMenu.add(total);
    	totalclearexitMenu.add(clear);
    	totalclearexitMenu.add(exit);
    	
    	//Create Menu Bar
    	JMenuBar bar = new JMenuBar();
    	
    	//Add Top Level(s) To Menu Bar
    	bar
    
    Java java sales help question

  • Java Applet Help
    U User 10694570

    I am having trouble in only the last line of code. (I think!) The first label prompts the user for their name. If they click the button, then it will change the second label to read "Hello, (username)!" Can anyone give me some pointers?

    import java.applet.Applet;
    import java.awt.Button;
    import java.awt.Color;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.JLabel;
    import javax.swing.JTextField;

    public class Greeting extends Applet implements ActionListener {

    JLabel labelName = new JLabel("Please enter your name.");
    JTextField textField = new JTextField(20);
    Button button = new Button("GREET");
    JLabel labelResult = new JLabel("Result goes here.");
    
    String userResult = "";
    
    public void init() {
    	setSize(500, 500);
    	setBackground(Color.yellow);
    	add(labelName);
    	add(textField);
    	add(button);
    	add(labelResult);
    
    	button.addActionListener(this);
    }
    
    public String getText() {
    	return userResult;
    }
    
    public void setName(String result){
    	userResult = result;
    }
    
    public void actionPerformed(ActionEvent event) {
    	if (event.getSource() == button) {
    		labelResult.setText("Hello, " + userResult);
    	}
    
    }
    

    }

    Java java help question

  • Code Help!
    U User 10694570

    I really appreciate your help... Apparently, I'm EXTREMELY dumb with this. So you mean... That I have:

    System.out.print("Enter class credits: ");
    String credits = input.nextLine();

    And I need to change it to:

    System.out.print("Enter class credits: ");
    double credits = input.nextDouble();

    Where would I put the:

    info.addClass(credits, grade);

    When I added it after the grade code, it messed up my prompts.

    Java help java question

  • Code Help!
    U User 10694570

    I guess I don't understand what I am supposed to do to call them...

    Java help java question

  • Code Help!
    U User 10694570

    I cannot figure out what I am doing wrong. I just don't feel like I'm ever going to understand all of this. My prompts and loop are working fine. However, I am not getting any output. I'm sure it's a fairly simple thing, but I just don't see it so I can't know for sure what I need to fix. I have watched all the videos and looked through my textbook and the internet, but I need someone to "dumb" it down for me, I guess. Thank you, in advance, for your patience and help.

    import java.util.Scanner;

    public class StudentInfoTest
    {
    public static void main(String[] args)
    {
    //Initiate scanner.
    Scanner input = new Scanner(System.in);

    	//Declare Variables.
    	String answer = "";
    	double GPA = 0.0;
    	
    	//Create Object		
    	StudentInfo info = new StudentInfo(null, 0, 0);
    	
    	//Prompt for and store student name.
    	System.out.print("Enter student name: ");
    	String name = input.nextLine();
    	info.setName(name); 
    
    	//Prompt for class credits and letter grade.
    	//Loop until answer is "N".
    	do 
    	{
    	System.out.print("Enter class credits: ");
    	String credits = input.nextLine();
    	
    	System.out.print("Enter letter grade: ");
    	String grade = input.nextLine();
    
    	System.out.print("Add another class? (Y or N): ");
    	
    	answer = input.nextLine();
    	}
    	while (answer.equals("Y"));
    	
    	System.out.printf(name + ", Your GPA is %.2f/n.", GPA);
    	
    }//Ends Main
    

    }//Ends Class

    public class StudentInfo {

        //Variables
        private String studentName;
        private double totalPoints;
        private double totalCredits;
    
        //Constructor
        public StudentInfo(String name, double points, double credits)
        {
            //Initialize Variables
            studentName = name;
            totalPoints = points;
            totalCredits = credits;
        }
    
        //Create "Set" Functions
        public void setName(String name)
        {
            studentName = name;
        }
    
        //Create "Get" Functions
        public String getName()
        {
            return studentName;
        }
    
            public void addClass(double credits, String grade)
            {
                double points = 0.0;
    
                if(grade == "A" | grade == "a")
                    points = 4.0;
                if(grade == "B" | grade == "b")
                    points = 3.0;
                if(grade == "C" | grade == "c&quo
    
    Java help java question

  • Sales Tracking Assignment & Unfinished Code
    U User 10694570

    I am still working on this myself, but I am kind of just needing a little reassurance that I am on the right track or a push in the right direction. This is all really new to me, and I'm honestly getting a little overwhelmed. Thank you! You must create a sales tracking program named SalesTracking.java. This program will use arrays to store and process monthly sales as well as compute average yearly sales, total sales for the year, and which month had the highest sales and which month had the lowest sales. You should use parallel arrays. Your first array (monthArray) should be initialized with all of the months. This array should have 12 locations of course. Your other array should be named monthlySales. Like your monthArray, this array should be 12 locations that store the amount of sales for each month. The program should prompt the user for the sales for each month starting with January. The arrays (monthlySales and monthArray) should be created in main and passed to the methods as needed. Your program should have methods that do the following. getSales(monthArray, monthlySales): This method receives the monthArray and monthlySales arrays as arguments. It prompts the users for the sale for each month. This amount should be stored and returned into the corresponding location in the monthlySales array. For example, January sales should be stored in the first location, February sales should be stored in the second location, and so forth. computeTotalSales(monthlySales): This method receives the monthly sales array as an argument and returns the total sales of the year. computeAverageSales(monthlySales): This method receives the monthly sales array as an argument and returns the average sales for the year. computeHighestMonth(monthlySales): This method receives the monthly sales array as an argument. This method will search and compare the values of the monthly sales array for the highest value. The method will return the index(or location in the array) of the month with the highest value. computeLowestMonth(monthlySales): This method receives the monthly sales array as an argument. This method will search and compare the values of the monthly sales array for the lowest value. The method will return the index (or location in the array) of the month with the lowest value. displaySaleInfo(totalSales, averageSales, highestMonth, highestSales, lowestMonth, lowestSales): This method will receive the total yearly sales, average monthly sale, the month with the highest sales, as well as the s

    Java java database data-structures sales tutorial

  • RESOURCE Role
    U User 10694570

    If the DBA creates a new user and gives that user the RESOURCE role only, can the new user successfully connect to the database?

    Linux, Apache, MySQL, PHP database question learning

  • SQL - Determining Markup %
    U User 10694570

    I am having trouble figuring out how to write the following problem... "Many organizations use percentage of markup (e.g., profit margin) when analyzing financial data. To determine the percentage of markup for a particular item, simply subtract the cost for the item from the retail price to obtain the dollar amount of profit, and then divide the profit by the cost of the item. The resulting solution is then multiplied by 100 to determine the percent of markup. Using a SELECT statement, display the title of each book and its percent of markup. For the column displaying the percent of markup, use “Markup %” as the column heading."

    Linux, Apache, MySQL, PHP html database help tutorial learning

  • SQL
    U User 10694570

    Can anyone tell me what I am doing wrong? I am getting an error message on line 9 (Locid)... Create table Course_Section ( Csecid NUMBER(8) CONSTRAINT PK_COURSE_SECTION PRIMARY KEY, Cid NUMBER(6) NOT NULL CONSTRAINT FK_COURSE_SECTION REFERENCES COURSE(Cid), Termid NUMBER(5) NOT NULL CONSTRAINT FK_COURSE_SECTION REFERENCES TERM(Termid), Secnum NUMBER(5) NOT NULL, Fid NUMBER(4) CONSTRAINT FK_COURSE_SECTION REFERENCES FACULTY(Fid), Day VARCHAR(10) Locid NUMBER(5) CONSTRAINT FK_COURSE_SECTION REFERENCES FACULTY(Locid), Maxenrl NUMBER(4) NOT NULL, Currenrl NUMBER(4) NOT NULL, );

    Linux, Apache, MySQL, PHP database help question learning

  • Guidance...
    U User 10694570

    This is what I have so far... Am I on the right track?

    Public Class frmSalesData
    Dim intCars, intTickets, intPopcorn, intCandy As Integer

    Private Sub btnExit\_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
        Me.Close()
    End Sub
    
    Private Sub btnClear\_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
        Me.txtNumCars.Clear()
        Me.txtNumTickets.Clear()
        Me.txtNumPopcorn.Clear()
        Me.txtNumCandy.Clear()
        Me.lblTotal.Text = Nothing
        Me.txtNumCars.Focus()
    End Sub
    
    Private Sub btnCalculate\_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
        Dim strMessage As String
        Dim dblNumCars, dblNumTickets, dblNumPopcorn, dblNumCandy As Double
        Dim dblTotalSales As Double
    
        If radRegular.Checked = True Then
            Me.lblTotal.Text = "Tonight was a REGULAR night."
        ElseIf radCar.Checked = True Then
            Me.lblTotal.Text = "Tonight was a CAR night."
    
        End If
    
        Double.TryParse(Me.txtNumCars.Text, dblNumCars)
        Double.TryParse(Me.txtNumTickets.Text, dblNumTickets)
        Double.TryParse(Me.txtNumPopcorn.Text, dblNumPopcorn)
        Double.TryParse(Me.txtNumCandy.Text, dblNumCandy)
    
        dblTotalSales = dblNumTickets + dblNumPopcorn + dblNumCandy
    
        strMessage = "The total number of cars present was: " & dblNumCars.ToString() & \_
                     "The total number of tickets sold was: " & dblNumTickets.ToString() & \_
                     "The total popcorn sales were: " & dblNumPopcorn.ToString("N2") & \_
                     "The total candy sales were: " & dblNumCandy.ToString("N2")
    
        Me.lblTotal.Text = strMessage
    
    
    End Sub
    

    End Class

    Visual Basic sales tutorial question

  • Guidance...
    U User 10694570

    Can someone please guide me through this?

    In this program you will create a Windows Form application that will calculate and display the money made by a drive-in movie theater each night. The movie theater has two types of nights. A “Regular” night is where each person in a guest car has to buy a ticket, and each ticket costs $10. A “Car” night is a special promotion where there is one price per car of $15, no matter how many guests are in the car.

    In addition to the cost of entry (either Regular or Car), the theater sells popcorn and candy but the price of the items depends on the type of night. On a Regular night popcorn costs $1.50 per box and on a special Car night popcorn costs $2.00 per box. On a Regular night candy cost $2.25 per candy box, while on a special Car night candy cost $3.00 per box.

    On any night, the maximum number of cars allowed in is 500 and the maximum number of individual tickets is 3,000; the theater can produce 4,500 bags of popcorn each night and has 4,000 candy items.

    Once the total sales are calculated, the program will display a summary message with the type of night, the total number of cars, the total ticket sales, the total popcorn sales, the total candy sales, and the total sales amount.

    Visual Basic sales tutorial question

  • Help!
    U User 10694570

    Excuse me. I don't understand. I'm just learning this all, and it's very confusing. :(

    Visual Basic help

  • Help!
    U User 10694570

    I am trying really hard, but I'm just not getting this... This is what I need to do... Set prompt = “Enter sides of the square” Show Input Box Convert string input to length Area = length * length Set output = “Square of side length “ + length + = “: “ + area This is where I am at... Dim prompt, sideLength As String Dim area, length As Double prompt = InputBox("Enter sides of the square.") sideLength = Convert.ToDouble(length) area = length * length Me.lblOutput.Text = "Square of side length " & length & ": " & area

    Visual Basic help

  • Help... Again...
    U User 10694570

    Oh, my goodness! I fixed the problem, and now everything works! Thank you!

    Visual Basic help tutorial question

  • Help... Again...
    U User 10694570

    This is what I have so far, but I can't get past putting in the number of units to use. I feel like I'm never going to get a hang of this coding stuff. :( Module Module1 Dim miles As Decimal = 0 Dim kilometers As Decimal = 0 Dim answer As String Sub Main() Console.WriteLine("Do you want to convert miles or kilometers?") answer = Console.ReadLine() If answer = "miles" Then Console.WriteLine("What is the number of miles?") Console.ReadLine() Call convertMilesToKilometers() Console.WriteLine("The converted value is: " & kilometers) ElseIf answer = "kilometers" Then Console.WriteLine("What is the number of kilometers?") Console.ReadLine() Call convertKilometersToMiles() Console.WriteLine("The converted value is: " & miles) End If Console.ReadLine() End Sub Function convertMilesToKilometers() As Decimal kilometers = miles / 0.62137 Return kilometers End Function Function convertKilometersToMiles() As Decimal miles = kilometers * 0.62137 Return miles End Function End Module

    Visual Basic help tutorial question

  • Help... Again...
    U User 10694570

    Assignment It’s often necessary to convert between units. In this exercise, you will create two functions for converting between units of distance. The first function will be called ConvertMilesToKilometers(), which will accept one parameter for the number of miles. It will return the equivalent number of kilometers. The second function will be called ConvertKilometersToMiles() and will accept kilometers as its parameter; this will return the equivalent number of miles. The main method will ask the user if he or she wants to convert miles to kilometers or kilometers to miles. It will then ask for the number of miles or kilometers. It will call the appropriate method and display the converted value. To convert miles to kilometers, divide miles by 0.62137. To convert kilometers to miles, multiply kilometers by 0.62137. Example Do you want to convert to Miles or Kilometers? (M or K): K Enter number of Kilometers: 3.5 3.5 kilometers equals 2.174795 miles.

    Visual Basic help tutorial question

  • Rounding To 2 Decimal Places
    U User 10694570

    How do I code this to round my results to 2 decimal places? Module Module1 Dim itemQuantity As Integer = 0 Dim itemPrice As Decimal = 0 Dim totalSales As Decimal = 0 Dim stateName As String Dim taxRate As Decimal = 0 Dim taxAmount As Decimal = 0 Dim customerName As String Sub Main() Console.WriteLine("Please enter your name.") customerName = Console.ReadLine() Console.WriteLine("Please enter your state: NJ, FL, or NY") stateName = Console.ReadLine() Console.WriteLine("Please enter the number of items purchased.") itemQuantity = Console.ReadLine() Console.WriteLine("Please enter the price of the item.") itemPrice = Console.ReadLine() Call computeTotal() Call computeTax() Console.WriteLine("The total sales for " & customerName & " are " & totalSales & " .") Console.WriteLine("The tax amount is " & taxAmount & " based on a tax rate of " & taxRate & " .") Console.WriteLine("The total with tax is " & totalSales + taxAmount & " .") Console.ReadLine() End Sub Function computeTotal() As Decimal totalSales = itemQuantity * itemPrice Return totalSales End Function Function computeTax() As Decimal If stateName = "NJ" Then taxRate = 0.07 ElseIf stateName = "FL" Then taxRate = 0.06 ElseIf stateName = "NY" Then taxRate = 0.04 End If taxAmount = totalSales * taxRate Return taxAmount End Function End Module

    Visual Basic question sales
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups