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
Travka [436]
2 years ago
8

Hello! I am a new coder, so this is a simple question. But I am trying to create a code where you enter a number, then another n

umber, and it divides then multiply the numbers. I put both numbers as a string, and as result when i tried to multiply/divide the numbers that were entered, an error occurred. How can i fix this?
using System;

namespace Percentage_of_a_number
{
class Program
{
static object Main(string[] args)
{
Console.WriteLine("Enter percentage here");
string Percentage = Console.ReadLine();


Console.WriteLine("Enter your number here");
string Number = Console.ReadLine();

String Result = Percentage / 100 * Number;


}
}
}
Computers and Technology
1 answer:
slavikrds [6]2 years ago
6 0

no longer returns an error but your math seems to have something wrong with it, always returns 0

Console.WriteLine("Enter a percentage here");

   int Percent = int.Parse(Console.ReadLine());

   Console.WriteLine("Enter your number here");

   int Number = int.Parse(Console.ReadLine());

   int result = Percent / 100 * Number;

You might be interested in
How can I link two classes together with spigot to make it so I can open a method within the said class. Trying to open my class
Andreyy89

Answer:

add the following code to your bar class

Explanation:

public Bar(Commands n) { }

5 0
2 years ago
Jordan likes to use his smartphone in his car. He uses it as a navigation device and connects it via Bluetooth to listen to musi
Levart [38]

Answer:

I think A Bluetooth receiver is causing the smartphone to over heat

8 0
2 years ago
Assume that d is a double variable. Write an if statement that assigns d to the int variable i if the value in d is not larger t
mamaluj [8]

Answer:

That's because the value has reached the size limit of the int data type. ... you should use long rather than int , because long can store much larger numbers than int . If ... In other words, a float or double variable can't accurately represent 0.1 . ... If you're using Java to measure the size of your house, you'd need an electron ...

Explanation:

3 0
3 years ago
Write a program that produces the following output (where the user may enter any positive integer under 10):______
Mekhanik [1.2K]

Answer:

// The Scanner class is imported to allow the program receive user input

import java.util.Scanner;

// The class is defined called Solution

public class Solution {

   // The main method is defined which begin program execution

   public static void main(String args[]) {

     // Scanner object 'scan' which receive user input from the keyboard

     Scanner scan = new Scanner(System.in);

     // the userInput variable is initially set to 1 (true) to allow the program continue prompting the user for input

     int userInput = 1;

     // while loop which continue execution as long as the userInput is greater than 0 and less than 10

     while (userInput > 0 && userInput < 10){

         // Prompts is displayed to the user to enter number below 10

         System.out.println("Enter a positive integer under 10:__________");

         // the next input is assigned to userInput

         userInput = scan.nextInt();

     }      

   }

}

Explanation:

The above code continue prompting the user to input an integer as long as the input is greater than 0 and less than 10.

3 0
3 years ago
What are some recent inventions that have improved the quality of your life?
Eva8 [605]
Phones, they help me with school work and provide entertainment.
4 0
3 years ago
Other questions:
  • [PROGRAMMING] A ____ signal indicates that a specific amount of time should pass before an action starts.
    13·1 answer
  • By default, a word document generally displays in ____ view.
    9·1 answer
  • What can you do to make sure you have a healthy credit report
    13·2 answers
  • Antivirus software installed to scan and monitor malware activities on a server or workstation would be identified as a ________
    8·1 answer
  • Someone who is young, lacks funds, and really wants to gain technical skills while serving his or her nation should consider
    8·1 answer
  • 5. The stage of engine operation when both the intake and exhaust valves are closed is the _______ stage.
    5·1 answer
  • Why do contour lines never cross?
    5·1 answer
  • Define input hardware​
    12·1 answer
  • Which statements about grades are accurate? Check all that apply. Grades help indicate how well a student is understanding a cer
    13·1 answer
  • _________ is the method used by password crackers who work with pre-calculated hashes of all passwords possible within a certain
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!