Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

solved problem of lowercase letters #1266

Open
wants to merge 1 commit into
base: master
from
Open
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -23,12 +23,31 @@

public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String n;
int b1, b2;
String n ;

int b1, b2,ifzero = 0;
while (true) {
try {
System.out.print("Enter number: ");
n = in.next();


char[] digits = n.toCharArray();
for (int i = 0 ; i < digits.length; i++)
{
//converting lower case letters to upper case letters
if (digits[i] >= 'a' && digits[i] <= 'z')
digits[i] = (char)(digits[i] - 32);
//checking if the input is 0
if (digits[i] =='0') {}
else
{
ifzero++;
}
}
n = String.valueOf(digits);


System.out.print("Enter beginning base (between " + MINIMUM_BASE + " and " + MAXIMUM_BASE + "): ");
b1 = in.nextInt();
if (b1 > MAXIMUM_BASE || b1 < MINIMUM_BASE) {
@@ -45,6 +64,14 @@ public static void main(String[] args) {
System.out.println("Invalid base!");
continue;
}

// in the case of input 0
if (ifzero == 0)
{
System.out.println(0);
System.exit(0);
}

break;
} catch (InputMismatchException e) {
System.out.println("Invalid input.");
@@ -88,7 +115,7 @@ public static boolean validForBase(String n, int base) {
* @return n in base b2.
*/
public static String base2base(String n, int b1, int b2) {
// Declare variables: decimal value of n,
// Declare variables: decimal value of n,
// character of base b1, character of base b2,
// and the string that will be returned.
int decimalValue = 0, charB2;
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.